Exemple #1
0
        public void SpawnBuilding(Building a_Building, Vector2UInt a_LLCornerPos)
        {
            Vector3 offset = a_Building.Size.ToVector2() * 0.5f;

            a_Building.transform.position = new Vector3(a_LLCornerPos.X, a_LLCornerPos.Y, -1) + offset;
            a_Building.transform.parent   = m_BuildingsObj.transform;
            Buildings.Add(a_Building);
        }
Exemple #2
0
        private void Start()
        {
            Camera.main.orthographicSize = INITIAL_ZOOM_LVL;
            m_GameBoardSizeTiles         = GameWorld.Instance.BoardSizeInTiles;
            m_TargetZoomLvl = INITIAL_ZOOM_LVL;

            var pos2D = GameWorld.Instance.BoardSizeInTiles * 0.5f;

            Camera.main.transform.position = new Vector3(pos2D.x, pos2D.y, -10);
        }
Exemple #3
0
        private void Start()
        {
            var genScript = JsonUtility.FromJson <WorldGenerationScript>(m_GenerationFile.text);

            foreach (var obj in genScript.Objects)
            {
                var tokens = obj.Type.ToUpper().Split('.');
                Debug.Assert(tokens.Length >= 2);
                var entityType = (EntityType)Enum.Parse(typeof(EntityType), tokens[0]);

                Debug.Assert(obj.Pos.Length == 2);
                var pos = new Vector2UInt(obj.Pos[0], obj.Pos[1]);

                switch (entityType)
                {
                case EntityType.BUILDING:
                    var building = Instantiate(Prefabs.Instance.Building).GetComponent <Building>();
                    building.Initialize(GameLogic.Instance.PlayerTeam, new Vector2UInt(2, 3));
                    GameWorld.Instance.SpawnBuilding(building, pos);
                    break;

                case EntityType.UNIT:
                    Debug.Assert(tokens.Length >= 3);
                    var family = (UnitFamily)Enum.Parse(typeof(UnitFamily), tokens[1]);

                    switch (family)
                    {
                    case UnitFamily.STAVE:
                        Debug.Assert(tokens.Length == 4);
                        var function = (UnitFunction)Enum.Parse(typeof(UnitFunction), tokens[2]);
                        var value    = (NoteValue)Enum.Parse(typeof(NoteValue), tokens[3]);
                        var unit     = Instantiate(Prefabs.Instance.StaveUnit).GetComponent <StaveUnit>();
                        unit.Initialize(GameLogic.Instance.PlayerTeam, function, value);
                        GameWorld.Instance.SpawnUnit(unit, pos.ToVector2() + Vector2.one * 0.5f);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Exemple #4
0
 public void Initialize(Team a_Team, Vector2UInt a_Size)
 {
     Initialize(a_Team, MainRenderer.sprite, GlowRenderer.sprite);
     Size = a_Size;
 }