Exemplo n.º 1
0
        public UnitView AddUnit(PlayerData player, UnitData unit, Color tint)
        {
            string edenPath   = player.isEden ? "Eden/" : "Plymouth/";
            string weaponType = "";

            if (unit.typeID == map_id.GuardPost || unit.typeID == map_id.Lynx || unit.typeID == map_id.Panther || unit.typeID == map_id.Tiger)
            {
                weaponType = "_" + ((map_id)unit.cargoType).ToString();
            }
            else if (unit.typeID == map_id.CargoTruck && unit.cargoType != 0)
            {
                // Cargo truck type
                if (unit.cargoType >= 1 && unit.cargoType <= 7)
                {
                    weaponType = "_" + ((TruckCargo)unit.cargoType).ToString();
                }
                else if (unit.cargoType == 8)
                {
                    weaponType = "_Starship";
                }
                else if (unit.cargoType == 9)
                {
                    weaponType = "_Wreckage";
                }
                else
                {
                    weaponType = "_GeneBank";
                }
            }

            if (IsStructure(unit.typeID))
            {
                // Add structure
                GameObject    goUnit = CreateUnit("Structures/" + edenPath + unit.typeID.ToString() + weaponType, m_UnitContainer, unit.id, new Vector2Int(unit.position.x, unit.position.y));
                StructureView view   = goUnit.GetComponent <StructureView>();
                view.Initialize(player, unit, tint);
                return(view);
            }
            else
            {
                // Add vehicle
                GameObject  goUnit = CreateUnit("Vehicles/" + edenPath + unit.typeID.ToString() + weaponType, m_UnitContainer, unit.id, new Vector2Int(unit.position.x, unit.position.y));
                VehicleView view   = goUnit.GetComponent <VehicleView>();
                view.Initialize(player, unit, tint);
                return(view);
            }
        }
Exemplo n.º 2
0
 public void RemoveUnit(UnitData unit)
 {
     if (IsStructure(unit.typeID))
     {
         // Remove structure
         List <StructureView> views = new List <StructureView>(m_UnitContainer.GetComponentsInChildren <StructureView>());
         StructureView        view  = views.Find((v) => v.unit == unit);
         Destroy(view.gameObject);
     }
     else
     {
         // Remove vehicle
         List <VehicleView> views = new List <VehicleView>(m_UnitContainer.GetComponentsInChildren <VehicleView>());
         VehicleView        view  = views.Find((v) => v.unit == unit);
         Destroy(view.gameObject);
     }
 }