Exemple #1
0
 // Use this for initialization
 void Start()
 {
     containerSkills = GameObject.FindGameObjectWithTag("CombatController");
     containerPlayer = GameObject.FindGameObjectWithTag("Player");
     skills          = containerSkills.GetComponent <Skills>();
     startCombat     = containerSkills.GetComponent <StartCombat>();
     player          = containerPlayer.GetComponent <Player>();
     maxLife         = life;
     BkgVida.GetComponent <Image>().fillAmount = life / maxLife;
 }
Exemple #2
0
    private void Awake()
    {
        startCombatState = new StartCombat(this);
        playerTurnState  = new PlayerTurn(this);
        enemyTurnState   = new EnemyTurn(this);
        battleLostState  = new BattleLost(this);
        battleWonState   = new BattleWon(this);
        blankState       = new BlankState(this);
        currentState     = blankState;

        missionButtonArray = GameObject.FindGameObjectsWithTag("MissionButton");
    }
    private void Awake()
    {
        startCombatState = new StartCombat(this);
        playerTurnState = new PlayerTurn(this);
        enemyTurnState = new EnemyTurn(this);
        battleLostState = new BattleLost(this);
        battleWonState = new BattleWon(this);
        blankState = new BlankState(this);
        currentState = blankState;

        missionButtonArray = GameObject.FindGameObjectsWithTag("MissionButton");
    }
Exemple #4
0
    private void OnEvent(EventData photonEvent)
    {
        byte eventCode = photonEvent.Code;

        if (eventCode == START_COMBAT)
        {
            object[]          data    = (object[])photonEvent.CustomData;
            int[]             damages = (int[])data[0];
            List <CardPhoton> cards   = (List <CardPhoton>)DataHandler.Instance.ByteArrayToObject((byte[])data[1]);
            bool heroAttacking        = (bool)data[2];

            if (heroAttacking)
            {
                GameManager.Instance.ActiveHero(true).AdjustMana(GameManager.Instance.ActiveHero(true).Damage, false);
            }

            TapMinions(cards);

            GameManager.Instance.StartCombatDamageUI.gameObject.SetActive(true);
            GameManager.Instance.alliedStealthDamageCounter.text     = damages[0].ToString();
            GameManager.Instance.alliedLifestealDamageCounter.text   = damages[1].ToString();
            GameManager.Instance.alliedPoisonTouchDamageCounter.text = damages[2].ToString();
            GameManager.Instance.alliedDamageCounter.text            = damages[3].ToString();

            StartCombat sc = GameManager.Instance.ActiveHero(true).AttackButton.parent.GetComponent <StartCombat>();
            sc.totalDamage = new Dictionary <string, int>
            {
                { "stealth", damages[0] },
                { "lifesteal", damages[1] },
                { "poisonTouch", damages[2] },
                { "damage", damages[3] }
            };

            EventManager.Instance.PostNotification(EVENT_TYPE.DEFEND_AGAINST);
            GameManager.Instance.shopButton.interactable = false;
        }
        else if (eventCode == ASSIGN_DEFENDING_DAMAGE)
        {
            object[]                 data           = (object[])photonEvent.CustomData;
            List <DamagePhoton>      damageToAssign = (List <DamagePhoton>)DataHandler.Instance.ByteArrayToObject((byte[])data[0]);
            Dictionary <string, int> heroDamage     = (Dictionary <string, int>)DataHandler.Instance.ByteArrayToObject((byte[])data[1]);
            bool minionDefeated  = (bool)data[2];
            int  totalHeroDamage = 0;
            foreach (KeyValuePair <string, int> entry in heroDamage)
            {
                totalHeroDamage += entry.Value;
            }
            AssignDamageToDefenders(damageToAssign, heroDamage);
            if (totalHeroDamage > 0)
            {
                //Add Bleed to the queue
                EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.BLEED);
            }
            if (minionDefeated)
            {
                //Add Minion Defeated to the queue
                EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.MINION_DEFEATED);
            }

            GameManager.Instance.IsDefending = false;

            AssignDamageToAttackers();

            DefendListener dl = GameManager.Instance.GetComponent <DefendListener>();
            dl.ChangeUiForDefense(GameManager.Instance.IsDefending);
            GameManager.Instance.EnableOrDisablePlayerControl(true);
            GameManager.Instance.endButton.interactable = true;
            dl.ResetDamageUI();

            StartCombat sc = GameManager.Instance.ActiveHero(true).AttackButton.parent.GetComponent <StartCombat>();
            sc.totalDamage = new Dictionary <string, int>
            {
                { "stealth", 0 },
                { "lifesteal", 0 },
                { "poisonTouch", 0 },
                { "damage", 0 }
            };

            GameManager.Instance.instructionsObj.GetComponent <TMP_Text>().text = "";
        }
        else if (eventCode == ASSIGN_AFTER_EFFECT_SYNC_EVENT)
        {
            object[] data    = (object[])photonEvent.CustomData;
            int[]    minions = (int[])data[0];

            int i = 0;
            foreach (Transform card in GameManager.Instance.GetActiveMinionZone(true))
            {
                CardVisual cv = card.GetComponent <CardVisual>();
                if (cv.Md.MinionID == minions[i])
                {
                    cv.AdjustHealth(1, false);
                }

                i++;
            }
        }
    }