Ejemplo n.º 1
0
        private DiscreteTankControl GetControl(TankNode tankNode, WeaponNode weaponNode)
        {
            DiscreteTankControl control  = new DiscreteTankControl();
            ChassisComponent    chassis  = tankNode.chassis;
            MoveControl         control2 = new MoveControl {
                MoveAxis = chassis.EffectiveMoveAxis,
                TurnAxis = chassis.EffectiveTurnAxis
            };

            control.TurnAxis      = Mathf.RoundToInt(control2.TurnAxis);
            control.MoveAxis      = Mathf.RoundToInt(control2.MoveAxis);
            control.WeaponControl = Mathf.RoundToInt(weaponNode.weaponRotationControl.EffectiveControl);
            return(control);
        }
        public void OnMoveCommandDiscrete(MoveCommandServerEvent e, TankNode tank, [JoinByTank] WeaponNode weapon)
        {
            base.Log.Debug("RECEIVE DISCRETE");
            MoveCommand moveCommand = e.MoveCommand;
            Movement?   movement    = e.MoveCommand.Movement;

            this.ApplyMovement(tank, ref movement, false);
            MoveControl control = new MoveControl {
                MoveAxis = moveCommand.TankControlVertical,
                TurnAxis = moveCommand.TankControlHorizontal
            };

            this.ApplyMoveControl(tank, new MoveControl?(control));
            this.ApplyWeaponRotation(weapon, e.MoveCommand.WeaponRotation);
            this.ApplyWeaponControl(weapon, new float?(moveCommand.WeaponRotationControl));
        }
        public void OnTankAdded(NodeAddedEvent e, TankNode tank, [Context, JoinByTank] WeaponNode weapon)
        {
            base.Log.DebugFormat("INIT {0}", tank);
            TankMovementComponent tankMovement = tank.tankMovement;
            Movement?movement = new Movement?(tankMovement.Movement);

            this.ApplyMovement(tank, ref movement, true);
            MoveControl control = new MoveControl {
                MoveAxis = tankMovement.MoveControl.MoveAxis,
                TurnAxis = tankMovement.MoveControl.TurnAxis
            };

            this.ApplyMoveControl(tank, new MoveControl?(control));
            this.ApplyWeaponRotation(weapon, new float?(tankMovement.WeaponRotation));
            this.ApplyWeaponControl(weapon, new float?(tankMovement.WeaponControl));
            base.ScheduleEvent <TankMovementInitEvent>(tank);
        }