Inheritance: LandUnit
Ejemplo n.º 1
0
    MoveableUnitBase CreateMoveableUnit(string name)
    {
        MoveableUnitBase moveableUnit = null;

        switch (name.ToLower())
        {
        case "camper":
            moveableUnit = new CamperUnit
            {
                XDimension = 1,
                YDimension = 1
            };
            break;

        case "soldier":
            moveableUnit = new SoldierUnit
            {
                XDimension = 1,
                YDimension = 1
            };
            break;
        }

        return(moveableUnit);
    }
    // Use this for initialization
    void Start()
    {
        soldierUnit = SoldierUnit.Instance;
        shooterUnit = ShooterUnit.Instance;
        wallUnit    = WallUnit.Instance;
        bombUnit    = BombUnit.Instance;
        playerBase  = GameObject.FindGameObjectWithTag("PlayerBase");

        if (soldierUnit != null)
        {
            SetSoldierParams();
        }
        if (shooterUnit != null)
        {
            SetShooterParams();
        }
        if (wallUnit != null)
        {
            SetWallParams();
        }
        if (bombUnit != null)
        {
            SetBombUnitParams();
        }

        if (playerBase != null)
        {
            playerBase.GetComponent <DefenceHealth>().maxHealth = health;
        }
    }
Ejemplo n.º 3
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        m_unit      = animator.GetComponent <SoldierUnit>();
        m_transform = animator.GetComponent <Transform>();

        animator.SetBool("IsInRange", false);
    }
Ejemplo n.º 4
0
 public void RecruitSoldier(Globals.FactionNames factionId)
 {
     if (Stats.Control == (int)factionId)
     {
         SoldierUnit newSoldier = new SoldierUnit(this, factionId);
         PresentSoldiers.Add(newSoldier);
         Events.EventManager.TriggerEvent(EventNames.MilitaryRecruited, new UnitRecruitmentData()
         {
             NewlyRecruitedUnit = newSoldier
         });
     }
     else
     {
         Debug.Log("The faction: " + factionId.ToString() + " doesn´t have enough support to recruit a spy unit in: " + Stats.PopulationNodeName);
     }
 }
Ejemplo n.º 5
0
    private void OnInitializeCollectControlledMilitary()
    {
        GameObject[] populationNodeGameobjects = GameObject.FindGameObjectsWithTag("PopulationNode");

        if (populationNodeGameobjects == null)
        {
            Debug.Log("OnInitializeCollectControlledMilitary - PopulationNode GameObjects not found when looking for controlled military!");
            return;
        }

        for (int populationNodeIndex = 0; populationNodeIndex < populationNodeGameobjects.Length; populationNodeIndex++)
        {
            for (int soldierIndex = 0; soldierIndex < populationNodeGameobjects[populationNodeIndex].GetComponent <PopulationNode>().PresentSoldiers.Count; soldierIndex++)
            {
                SoldierUnit soldierUnit = populationNodeGameobjects[populationNodeIndex].GetComponent <PopulationNode>().PresentSoldiers[soldierIndex];
                if (soldierUnit.Faction == FactionId)
                {
                    ControlledMilitary.Add(populationNodeGameobjects[populationNodeIndex].GetComponent <PopulationNode>().PresentSoldiers[soldierIndex]);
                }
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Creates a soldier around the selected barrack
    /// </summary>
    public void SpawnSoldier()
    {
        if (_selectedProduct != null && _selectedProduct.name.Contains("Barrack"))
        {
            GameObject emptyGroundTile = _selectedProduct.GetComponent <BuildingViewModel>()
                                         .GetEmptyGroundTileNearTheSelectedBarrack(_createdGroundTileModels);

            if (emptyGroundTile != null)
            {
                emptyGroundTile.GetComponent <GroundTileViewModel>().IsWalkable = false;

                IProduct product        = new SoldierUnit("Soldier Unit", ProductType.Soldier, false, 1f);
                var      createdProduct = ViewFactory.Create <IProduct, SoldierViewModel>(product, Resources.Load <GameObject>("Prefabs/SoldierUnit"), null);
                createdProduct.name = "SoldierUnit";
                SoldierViewModel soldierViewModel = createdProduct.GetComponent <SoldierViewModel>();
                soldierViewModel.SetPosition(new Vector2(emptyGroundTile.transform.position.x, emptyGroundTile.transform.position.y));
                soldierViewModel.SetCurrentGroundTile(emptyGroundTile);
            }
            else
            {
                GameManager.Instance.GiveNotSuitableAreaForSpawnWarning();
            }
        }
    }
Ejemplo n.º 7
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     m_unit = animator.GetComponent <SoldierUnit>();
 }
 void Awake()
 {
     Instance = this;
 }