Exemple #1
0
    protected override void LoadComponents()
    {
        base.LoadComponents();
        unitTraits        = GetComponent <UnitTraits>();
        unitRelationships = GetComponent <UnitRelationships>();
        unitController    = GetComponent <UnitController>();
        unitAnim          = GetComponent <UnitAnimController>();
        attackTimer       = GetComponent <AttackTimer>();
        bodyController    = GetComponent <BodyPartController>();
        combatSkills      = GetComponent <CombatSkills>();

        attack1Parts = bodyController.attack1Parts; //main
        attack2Parts = bodyController.attack2Parts; //off
    }
Exemple #2
0
    private bool CheckThreatLevel(Transform unit)
    {
        UnitRelationships ur = unit.GetComponent <UnitRelationships>();

        if (ur == null) //not a collider with relationships or an incapacitated unit
        {
            return(false);
        }

        //figure out my relationship with the unit
        UnitRelationships.Factions unitFaction = ur.myFaction;
        int unitRelationship = 0;

        //dock unit if they are in an enemy faction

        for (int i = 0; i < r.myEnemyFactions.Length; i++)
        {
            if (unitFaction == r.myEnemyFactions[i])
            {
                unitRelationship -= 10;
            }
        }

        //add points if unit is in an allied faction
        for (int i = 0; i < r.myFriendlyFactions.Length; i++)
        {
            if (unitFaction == r.myFriendlyFactions[i])
            {
                unitRelationship += 10;
            }
        }

        Debug.Log(gameObject.name + "'s relationship with " + unit.name + " is " + unitRelationship);
        //this should cause this unit to choose the party they are more allied with while ignoring neutral fights
        if (unitRelationship < 0)
        {
            if (!unit.GetComponent <BodyPartController>().Incapacitated())
            {
                usm.currentThreat = unit; //set threat in case we decide to fight
                AlertOthers();
                return(true);
            }
        }
        return(false); //not a threat
    }
Exemple #3
0
    private IEnumerator ScanArea()
    {
        while (usm.unitRelationships == null || usm.unitTraits == null)
        {
            yield return(new WaitForSeconds(2f));
        }

        r = usm.unitRelationships;
        t = usm.unitTraits;

        while (true)
        {
            if (EnemyDetected())
            {
                stateMachine.RequestChangeState(StateMachine.States.FightOrFlight);
                break;
            }
            yield return(new WaitForSeconds(2f));
        }
        yield return(null);
    }