public override void ApplyEvent(ShipStateManager state)
 {
     state._shouldRender = false;
     state._shouldRemove = true;
 }
 public override void ApplyEvent(ShipStateManager state)
 {
     state._skillsLaunched.Add(this.Skill);
 }
 public override void ApplyEvent(ShipStateManager state)
 {
     base.ApplyEvent(state);
     state._team = this.Team;
     state._shouldRender = true;
 }
 public override void ApplyEvent(ShipStateManager state)
 {
     switch (NewStatus)
     {
         case ShipStatus.InGame:
             state._shouldRender = true;
             break;
         default:
             state._shouldRender = false;
             break;
     }
 }
 public override void ApplyEvent(ShipStateManager state)
 {
     state._lastPosition = new Vector3(this.X, this.Y);
     state._lastRotation = Quaternion.Euler(0, 0, this.Rotation * (180 / (float)Math.PI));
     state._lastTimeStamp = this.TimeStamp;
     state._shouldComputeTarget = true;
 }
 public abstract void ApplyEvent(ShipStateManager state);
示例#7
0
    private void OnStatusChanged(StatusChangedMsg statusChanged)
    {
        ShipStateManager ship;
        if (!_gameObjects.TryGetValue(statusChanged.shipId, out ship))
        {
            ship = new ShipStateManager();
            ship = _gameObjects.AddOrUpdate(statusChanged.shipId, ship, (_, val) => val);
        }

        ship.RegisterStatusChanged(statusChanged.status, this._client.Clock - this._client.LastPing / 2);
    }
示例#8
0
    private void OnPositionUpdate(Packet<IScenePeer> packet)
    {

        using (var reader = new BinaryReader(packet.Stream))
        {
            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                var id = reader.ReadUInt16();
                var x = reader.ReadSingle();
                var y = reader.ReadSingle();
                var rot = reader.ReadSingle();
                var time = reader.ReadInt64();


                ShipStateManager ship;
                if (!_gameObjects.TryGetValue(id, out ship))
                {
                    ship = new ShipStateManager();
                    ship = _gameObjects.AddOrUpdate(id, ship, (_, val) => val);
                }

                ship.RegisterPosition(x, y, rot, time);
            }
        }
    }
示例#9
0
    //private void OnShipAdded(Packet<IScenePeer> obj)
    //{

    //    var shipInfos = obj.ReadObject<ShipCreatedDto>();
    //    var rot = Quaternion.Euler(0, 0, shipInfos.rot * (180 / (float)Math.PI));
    //    var ship = new Ship { Id = shipInfos.id, LastRot = rot, TargetRot = rot, Target = new Vector3(shipInfos.x, shipInfos.y), Last = new Vector3(shipInfos.x, shipInfos.y), TargetDate = DateTime.UtcNow };
    //    UnityEngine.Debug.Log(string.Format("Ship {0} added ", shipInfos.id));

    //    _gameObjects.Add(ship.Id, ship);

    //}

    private void OnShipAdded(ShipCreatedDto[] shipDtos)
    {
        foreach (var shipDto in shipDtos)
        {
            ShipStateManager ship;
            if (!_gameObjects.TryGetValue(shipDto.id, out ship))
            {
                ship = new ShipStateManager();
                ship = _gameObjects.AddOrUpdate(shipDto.id, ship, (_, val) => val);
            }

            ship.RegisterCreation(shipDto);
        }
    }