コード例 #1
0
        //The server uses this to create a unit without sprites and junk.
        public static Unit InstantiateUnitFromMsg(CreateUnitMsg msg)
        {
            var newUnitObject = Object.Instantiate(Unit.BaseUnit, Vector3.zero, Quaternion.identity);
            var newUnit       = newUnitObject.GetComponent <Unit>();

            newUnit.PlayerId      = msg.PlayerId;
            newUnit.UnitId        = msg.UnitId;
            newUnit.MaxHealth     = msg.MaxHealth;
            newUnit.CurrentHealth = msg.MaxHealth;
            newUnit.MaxMoves      = msg.MaxMoves;
            newUnit.MovesLeft     = msg.MaxMoves;
            newUnit.Scale         = msg.Scale;
            newUnit.CreateMoveCostDictFromArray(msg.MoveCost);
            //It'd be weird to have too much reference to the tiles here, so we'll do all that jazz elsewhere.
            return(newUnit);
        }
コード例 #2
0
ファイル: SpawnUnitTest.cs プロジェクト: Krosantos/Space-4X
        //Test function! Kill me later!
        public void TestShips()
        {
            Debug.Log("Spawning it upppppp");
            var blueTile = GameState.Me.HexMap.AllTiles[74, 67];
            var redTile  = GameState.Me.HexMap.AllTiles[75, 68];


            var testUnitMsg = new CreateUnitMsg
            {
                MaxHealth = 3,
                MaxMoves  = 3,
                OnDeath   = "",
                Scale     = ShipScale.Small,
                Sprite    = "Sprites/PH_BlueShip",
                TileId    = blueTile.Id,
                Abilities = new[] { "" },
                MoveCost  = new[] { 1, 2, 999, 999, 999, 999, 1, 999, 0, 2, 1, 1 }
            };

            Player.Me.Client.Send(Messages.CreateUnit, testUnitMsg);
        }