Exemple #1
0
    void Awake()
    {
        // Set up references
        troopBehavior = GetComponent<TroopBehavior>();
        troopStats = GetComponent<TroopStats>();

        // Subscribe to appropriate events
        References.stateManager.changeState += onStateChange;
        troopBehavior.changeOfActions += onChangeAction;
        troopBehavior.onTroopDeath += onDeath;
    }
Exemple #2
0
    void Awake()
    {
        switch (transform.parent.tag)
        {
            case "Troop":
                troopStats = GetComponentInParent<TroopStats>();
                troopStats.alertOnDeath += death;
                break;

            case "Enemy":
                enemyStats = GetComponentInParent<EnemyStats>();
                enemyStats.alertOnDeath += death;
                break;
        }
        References.stateManager.nextLevel += nextLevel;
        rescale();
    }
Exemple #3
0
    void Awake()
    {
        // Set up references
        troopBehavior = GetComponent<TroopBehavior>();
        troopStats = GetComponent<TroopStats>();
        navigation = GetComponent<NavMeshAgent>();
        troopTargetSeeking = GetComponent<TroopTargetSeeking>();

        References.stateManager.changeState += onStateChange;
        troopBehavior.changeOfActions += onChangeAction;
        troopBehavior.changeOfIntentions += onChangeIntent;
        troopTargetSeeking.onTargetVisible += onTargetVisible;
        troopBehavior.onTroopDeath += onDeath;

        RaycastHit hitInfo;
        Physics.Raycast(new Ray(transform.position, Vector3.down), out hitInfo, 10000f);
        transform.position = new Vector3(hitInfo.point.x, hitInfo.point.y + (transform.localScale.y / 2), hitInfo.point.z);
    }
Exemple #4
0
    public void initialize(TroopStats troopStat)
    {
        /*
        Sprite top;
        Sprite middle;
        Sprite advance;
        Sprite bottom_normal;
        Sprite bottom_highlight;
        Data_Manager.ObtainTroopSprite(type, out top, out middle, out bottom_normal, out bottom_highlight, out advance);*/

        attachIcon(troopStat.Type.icon_top, ref icon_top, 3);
        attachIcon(troopStat.Type.icon_main, ref icon_middle, 2);
        attachIcon(troopStat.Type.icon_bottom, ref icon_bottom, 1);
        attachIcon(troopStat.Type.icon_advance, ref icon_advance, 4);
        attachIcon(troopStat.Type.icon_bottom_highlight, ref icon_highlight, 0);
        icon_bottom.GetComponent<SpriteRenderer>().color = factionColor;
        icon_advance.GetComponent<SpriteRenderer>().color = factionColor;
        setHighLight(false);
    }
 override public bool IsPossible()
 {
     // TODO: Rework this, it's ugly. We need to separate Governor vs Emperor scenarios.
     if (city.hasAction == false)
     {
         return(false);
     }
     else if (city.allegiance != leader.allegiance && city.allegiance != Allegiance.NONE)
     {
         return(false);
     }
     else if (!city.unitsForSale.Contains(troopClass))
     {
         return(false);
     }
     else if (leader.gold < TroopStats.GetTroopStat(troopClass, Stat.COST))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #6
0
    void Start()
    {
        lastXPosition = transform.position.x;

        troopStats = GetComponent<TroopStats>();
        troopAnimation = GetComponent<TroopAnimation>();

        if(!troopStats)Debug.LogWarning("Stats Script not found in " + name);
        if(!troopAnimation)Debug.LogWarning("Animation Script not found in " + name);

        if(pm)pm.ManageTroop (this);

        StartCoroutine ("LookForEnemy");
    }