コード例 #1
0
 public static void SetUnitToTalk(WM_Unit u)
 {
     if (!u.party.available || u.currentNode != GameManager.instance.player.currentNode)
     {
         return;
     }
     unitToTalk = u;
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: vikbha/Demon-Lair
    private void OnDestroy()
    {
        CombatManager.instance.RemoveUnit(this);
        WM_Unit u = transform.parent.GetChild(0).GetComponent <WM_Unit>();

        slot.UnloadSpellSlot();
        u.party.RemoveUnit(u);
    }
コード例 #3
0
ファイル: WM_party.cs プロジェクト: vikbha/Demon-Lair
 public void RemovingUnit(WM_Unit unit)
 {
     if (party.Count == 1)
     {
         Debug.Log(faction.gameObject.name + " is disbanding " + gameObject.name);
         faction.roamingUnits.Remove(this);
         Destroy(gameObject);
     }
     party.Remove(unit);
     Destroy(unit.gameObject);
 }
コード例 #4
0
ファイル: WM_CombatManager.cs プロジェクト: vikbha/Demon-Lair
    IEnumerator Fighting(int i)
    {
        // select a random faction, then select a random unit, it dmges a random enemy unit
        WM_Unit attacker = null;
        WM_Unit defender = null;
        battle  b;

        battleList[i] = new battle(battleList[i].party0, battleList[i].party1, true);
        b             = battleList[i];
        while (b.party0.party.Count > 0 && b.party1.party.Count > 0)
        {
            while (GameManager.FreezeTime)
            {
                yield return(new WaitForSeconds(0.2f));
            }

            if (b.party0 == fightingThePlayer || b.party1 == fightingThePlayer)
            {
                break;
            }

            yield return(new WaitForSeconds(0.5f));

            while ((attacker == null && defender == null) || !attacker.isAlive() || !defender.isAlive())
            {
                if (Random.Range(0, 1f) > 0.5f)
                {
                    attacker = b.party0.party[Random.Range(0, b.party0.party.Count)];
                    defender = b.party1.party[Random.Range(0, b.party1.party.Count)];
                }
                else
                {
                    defender = b.party0.party[Random.Range(0, b.party0.party.Count)];
                    attacker = b.party1.party[Random.Range(0, b.party1.party.Count)];
                }
            }

            defender.hp = defender.hp - attacker.atk;


            if (defender.hp <= 0)
            {
                defender.eliminated = true;
                defender.party.RemoveUnit(defender);
            }
        }
        yield return(null);
    }
コード例 #5
0
    public void EngageCombat(WM_Unit u)
    {
        if (inCombat)
        {
            return;           // prevent multiple calls
        }
        inCombat   = true;
        FreezeTime = true;
        WM_CombatManager.instance.IsFightingPlayer(u.party);
        List <Unit> fightingUnits = new List <Unit>();

        player.transform.parent.GetChild(1).gameObject.SetActive(true);
        u.transform.parent.GetChild(1).gameObject.SetActive(true);
        fightingUnits.Add(player.transform.parent.GetChild(1).GetComponent <Player>());
        fightingUnits.Add(u.transform.parent.GetChild(1).GetComponent <Enemy>());
        Debug.Log(fightingUnits.Count);
        CombatManager.instance.NewScene(fightingUnits);
        WM_Cam.enabled = false;
    }
コード例 #6
0
    public void SpawnNewUnits(int numberOfUnits, List <WM_party> duty)
    {
        GameObject party    = Instantiate(partyPrefab, transform);
        WM_party   tmpParty = party.GetComponent <WM_party>();

        tmpParty.currentNode = Base;
        tmpParty.faction     = this;
        party.name           = gameObject.name + " party " + partyCount;
        partyCount++;
        for (int i = 0; i < numberOfUnits; i++)
        {
            GameObject obj     = Instantiate(unitPrefab, party.transform);
            WM_Unit    tmpUnit = obj.transform.GetChild(0).GetComponent <WM_Unit>();
            tmpUnit.transform.position = Base.transform.position;
            tmpUnit.currentNode        = Base;
            obj.name            = party.name + " " + party.GetComponent <WM_party>().party.Count;
            tmpUnit.faction     = this;
            tmpUnit.currentNode = Base;
            tmpUnit.party       = tmpParty;
            tmpParty.party.Add(tmpUnit);
        }
        duty.Add(tmpParty);
    }
コード例 #7
0
ファイル: WM_party.cs プロジェクト: vikbha/Demon-Lair
 public void RemoveUnit(WM_Unit unit)
 {
     Debug.Log(gameObject.name + " is removing " + unit.gameObject.name);
     //unit.StopAllCoroutines();
     RemovingUnit(unit);
 }
コード例 #8
0
 public void DeselectUnitToTalk()
 {
     unitToTalk = null;
 }
コード例 #9
0
 public void UpdateUnitText(WM_Unit u)
 {
     gameObject.SetActive(true);
     unitText.text = "Hello. I am " + u.name + ". What do you want ?";
 }