Приветствую всех Форумчан.Неделю назад,когда мне было нечего делать,я решил скачать исходники Танков Онлайн Туториал.Кто не знает то это вот [Ссылки могут видеть только зарегистрированные пользователи. ]
Можно считать что этот "Туториал" у меня на компе.И вот я хочу узнать,возможно-ли как-нибудь включить режим "Спектатора".Дело вот в чём...Покопался с помощью Sothink SWF Decomiplier в файле hardware.swf.И нашел скрипт
Код:
package alternativa.tanks.camera
{
import alternativa.math.*;
import alternativa.tanks.shared.camera.*;
import alternativa.tanks.utils.*;
import flash.events.*;
import flash.ui.*;
import flash.utils.*;
import tutorial.*;
public class SpectatorCameraController extends Object implements CameraController
{
private var keyMap:Dictionary;
private var eventSource:IEventDispatcher;
private var camera:GameCamera;
private var mouseDown:Boolean;
private var controlBits:BitMask;
private var mouseDownX:Number;
private var mouseDownY:Number;
private var startCameraRotationX:Number;
private var startCameraRotationZ:Number;
private var localDirection:Vector3;
private var direction:Vector3;
private var position:Vector3;
private var rotation:Vector3;
private static const conSpeed:ConsoleVarFloat = new ConsoleVarFloat("cam_spd", 1300, 0, 10000);
private static const conAcceleration:ConsoleVarFloat = new ConsoleVarFloat("cam_acc", 4, 0, 1000000);
private static const conSmooth:ConsoleVarFloat = new ConsoleVarFloat("cam_smooth", 0.1, 0.001, 1);
private static const conMousePitchSensitivity:ConsoleVarFloat = new ConsoleVarFloat("m_pitch", -0.006, -100, 100);
private static const conMouseYawSensitivity:ConsoleVarFloat = new ConsoleVarFloat("m_yaw", -0.006, -100, 100);
private static const BIT_FORWARD:int = 0;
private static const BIT_BACK:int = 1;
private static const BIT_LEFT:int = 2;
private static const BIT_RIGHT:int = 3;
private static const BIT_UP:int = 4;
private static const BIT_DOWN:int = 5;
private static const BIT_ACCELERATION:int = 6;
private static const BIT_CAMERA_FIX_PLANE:int = 7;
public function SpectatorCameraController(param1:IEventDispatcher, param2:GameCamera)
{
this.keyMap = new Dictionary();
this.controlBits = new BitMask();
this.localDirection = new Vector3();
this.direction = new Vector3();
this.position = new Vector3();
this.rotation = new Vector3();
this.eventSource = param1;
this.setCamera(param2);
this.initKeyMap();
return;
}// end function
private function initKeyMap() : void
{
this.keyMap[Keyboard.W] = BIT_FORWARD;
this.keyMap[Keyboard.S] = BIT_BACK;
this.keyMap[Keyboard.A] = BIT_LEFT;
this.keyMap[Keyboard.D] = BIT_RIGHT;
this.keyMap[Keyboard.Q] = BIT_DOWN;
this.keyMap[Keyboard.E] = BIT_UP;
this.keyMap[Keyboard.SHIFT] = BIT_ACCELERATION;
this.keyMap[Keyboard.SPACE] = BIT_CAMERA_FIX_PLANE;
return;
}// end function
public function setCamera(param1:GameCamera) : void
{
this.camera = param1;
this.position.x = param1.x;
this.position.y = param1.y;
this.position.z = param1.z;
this.rotation.x = param1.rotationX;
this.rotation.y = param1.rotationY;
this.rotation.z = param1.rotationZ;
return;
}// end function
public function update(param1:int, param2:int) : void
{
var _loc_3:* = NaN;
if (this.camera != null)
{
_loc_3 = param2 / 1000;
if (this.controlBits.getBitValue(BIT_CAMERA_FIX_PLANE) > 0)
{
this.localDirection.x = this.getDirection(BIT_RIGHT, BIT_LEFT);
this.localDirection.y = 0;
this.localDirection.z = this.getDirection(BIT_FORWARD, BIT_BACK);
this.camera.getGlobalVector(this.localDirection, this.direction);
this.direction.z = 0;
if (this.direction.lengthSqr() > 0)
{
this.direction.normalize();
}
this.direction.z = -this.getDirection(BIT_DOWN, BIT_UP);
}
else
{
this.localDirection.x = this.getDirection(BIT_RIGHT, BIT_LEFT);
this.localDirection.y = this.getDirection(BIT_DOWN, BIT_UP);
this.localDirection.z = this.getDirection(BIT_FORWARD, BIT_BACK);
this.camera.getGlobalVector(this.localDirection, this.direction);
}
if (this.direction.lengthSqr() > 0)
{
this.direction.normalize();
}
if (this.controlBits.getBitValue(BIT_ACCELERATION) > 0)
{
this.direction.scale(conSpeed.value * conAcceleration.value * _loc_3);
}
else
{
this.direction.scale(conSpeed.value * _loc_3);
}
this.position.x = this.position.x + this.direction.x;
this.position.y = this.position.y + this.direction.y;
this.position.z = this.position.z + this.direction.z;
if (this.mouseDown)
{
this.rotation.x = this.startCameraRotationX + (GameData.stage.mouseY - this.mouseDownY) * conMousePitchSensitivity.value;
this.rotation.z = this.startCameraRotationZ + (GameData.stage.mouseX - this.mouseDownX) * conMouseYawSensitivity.value;
if (this.rotation.x > 0)
{
this.rotation.x = 0;
}
else if (this.rotation.x < -Math.PI)
{
this.rotation.x = -Math.PI;
}
}
this.camera.x = this.camera.x + (this.position.x - this.camera.x) * conSmooth.value;
this.camera.y = this.camera.y + (this.position.y - this.camera.y) * conSmooth.value;
this.camera.z = this.camera.z + (this.position.z - this.camera.z) * conSmooth.value;
this.camera.rotationX = this.camera.rotationX + (this.rotation.x - this.camera.rotationX) * conSmooth.value;
this.camera.rotationY = this.camera.rotationY + (this.rotation.y - this.camera.rotationY) * conSmooth.value;
this.camera.rotationZ = this.camera.rotationZ + (this.rotation.z - this.camera.rotationZ) * conSmooth.value;
}
return;
}// end function
private function getDirection(param1:int, param2:int) : int
{
return this.controlBits.getBitValue(param1) - this.controlBits.getBitValue(param2);
}// end function
public function activate() : void
{
this.eventSource.addEventListener(MouseEvent.MOUSE_DOWN, this.onMouseDown);
this.eventSource.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
this.eventSource.addEventListener(KeyboardEvent.KEY_UP, this.onKeyUp);
return;
}// end function
public function deactivate() : void
{
this.releaseMouse();
this.eventSource.removeEventListener(MouseEvent.MOUSE_DOWN, this.onMouseDown);
this.eventSource.removeEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
this.eventSource.removeEventListener(KeyboardEvent.KEY_UP, this.onKeyUp);
return;
}// end function
private function onMouseDown(event:MouseEvent) : void
{
this.mouseDown = true;
this.mouseDownX = event.stageX;
this.mouseDownY = event.stageY;
this.startCameraRotationX = this.camera.rotationX;
this.startCameraRotationZ = this.camera.rotationZ;
this.eventSource.addEventListener(MouseEvent.MOUSE_UP, this.onMouseUp);
return;
}// end function
private function onKeyUp(event:KeyboardEvent) : void
{
if (this.keyMap[event.keyCode] != null)
{
this.controlBits.clearBit(this.keyMap[event.keyCode]);
}
return;
}// end function
private function onKeyDown(event:KeyboardEvent) : void
{
if (this.keyMap[event.keyCode] != null)
{
this.controlBits.setBit(this.keyMap[event.keyCode]);
}
return;
}// end function
private function releaseMouse() : void
{
if (this.mouseDown)
{
this.eventSource.removeEventListener(MouseEvent.MOUSE_UP, this.onMouseUp);
this.mouseDown = false;
}
return;
}// end function
private function onMouseUp(event:MouseEvent) : void
{
this.releaseMouse();
return;
}// end function
}
}
Вот скриншоты:[URL="http://prnt.sc/agvm3o"/URL]
[URL="http://prnt.sc/agvmog"/URL]
(То что спаун и золотой ящик-это я уже сделал)
Вот этот код выполняет функцию выпадения дропа.Но к сожелению он выпадает один раз и всё.Если мне нужно к примеру 3 голда,я просто копирую 3 раза строчку
Цитата:
<medicine x="11165" y="11283" z="500"/>
и он падает 3 раза и всё.И мне бы хотелось чтобы при нажатии на любую кнопку,выполнялась этот код.(Это вообще возможно?)
Вот и всё.Буду очень благодарен если поможете.Спасибо что посмотрели данную тему.