Exemplo n.º 1
0
    protected virtual void Die(Entity cause = null)
    {
        ShowDeathEffect();
        GameManager.UnregisterEntity(owner);
        //owner.UnregisterListeners();

        Debug.Log(owner.gameObject + " has died");

        //if(owner.gameObject.tag == "Player") {
        //    GameManager.ReturnToMainMenu();
        //    return;
        //}

        //if(lootManager != null) {
        //    lootManager.SpawnLoot();
        //}

        EventData data = new EventData();

        data.AddMonoBehaviour("Target", owner);
        data.AddMonoBehaviour("Cause", cause);

        SystemGrid.EventManager.SendEvent(Constants.GameEvent.EntityDied, data);


        Destroy(owner.gameObject);
    }
Exemplo n.º 2
0
    public void SendImpactEvent()
    {
        EventData data = new EventData();

        data.AddMonoBehaviour("Card", targetCard);
        data.AddMonoBehaviour("VFX", this);

        Grid.EventManager.SendEvent(Constants.GameEvent.VFXLanded, data);
    }
Exemplo n.º 3
0
    private void SendEffectAppliedEvent(Entity target)
    {
        EventData data = new EventData();

        data.AddMonoBehaviour("Cause", Source);
        data.AddMonoBehaviour("Target", target);
        data.AddInt("EffectType", (int)effectType);

        EventGrid.EventManager.SendEvent(Constants.GameEvent.EffectApplied, data);
    }
Exemplo n.º 4
0
    public void BroadcastCombat(int attackerID, int defenderID)
    {
        CardVisual attacker = Finder.FindCardByID(attackerID);
        CardVisual defender = Finder.FindCardByID(defenderID);

        EventData data = new EventData();

        data.AddMonoBehaviour("Attacker", attacker);
        data.AddMonoBehaviour("Defender", defender);

        Grid.EventManager.SendEvent(Constants.GameEvent.Combat, data);
    }
Exemplo n.º 5
0
    public void AddCard(CardVisual card)
    {
        activeCards.Add(card);
        //card.currentDeck = this;

        EventData data = new EventData();

        data.AddMonoBehaviour("Card", card);
        data.AddMonoBehaviour("Deck", this);

        Grid.EventManager.SendEvent(Constants.GameEvent.CardEnteredZone, data);
    }
Exemplo n.º 6
0
    private void SendStatChangeEvent(Entity causeOfChagne, Entity targetOfChagnge, Constants.BaseStatType stat, float value)
    {
        EventData data = new EventData();

        data.AddMonoBehaviour("Cause", causeOfChagne);
        data.AddMonoBehaviour("Target", targetOfChagnge);
        data.AddInt("Stat", (int)stat);
        data.AddFloat("Value", value);

        //Debug.Log("Event Sent: " + stat.ToString() + " :: " + value);
        EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data);
    }
Exemplo n.º 7
0
    public void CheckDeath(int source, bool forceDeath, bool waitForVFX)
    {
        if (currentDeck.decktype == Constants.DeckType.SoulCrypt)
        {
            Debug.LogError(cardData.cardName + " is already dead, and was told to go to the soulcypt");
            return;
        }

        CardVisual causeOfDeath = Finder.FindCardByID(source);

        if (health <= 0 || forceDeath)
        {
            if (photonView.isMine)
            {
                //StartCoroutine(DisplayDeathEffect());

                if (!waitForVFX)
                {
                    StartCoroutine(DisplayDeathEffect());
                    StartCoroutine(RemoveCardVisualFromField(this));
                }
                else
                {
                    Grid.EventManager.RegisterListener(Constants.GameEvent.VFXLanded, OnDeathVisual);
                }

                if (keywords.Contains(Keywords.Interceptor))
                {
                    battlefieldPos.position -= interceptPos;
                }
            }

            Debug.Log(causeOfDeath.cardData.cardName + " has killed " + cardData.cardName);

            if (CheckSpecialAttributes(SpecialAttribute.AttributeType.Volatile) > 0)
            {
                HandleVolatile(causeOfDeath);
            }

            //currentDeck.TransferCard(photonView.viewID, owner.activeCrypt.GetComponent<Deck>().photonView.viewID);
            StartCoroutine(SendToCrypt());

            EventData data = new EventData();

            data.AddMonoBehaviour("DeadCard", this);
            data.AddMonoBehaviour("CauseOfDeath", causeOfDeath);

            Grid.EventManager.SendEvent(Constants.GameEvent.CreatureDied, data);
        }
    }
Exemplo n.º 8
0
    public void AddResource(int value)
    {
        currentValue += value;

        if (currentValue > maximumValue && maximumValue > 0)
        {
            currentValue = maximumValue;
        }

        //if (currentValue < maximumValue) {
        //    currentValue += value;
        //}

        //Debug.Log(resourceType.ToString() + " is being increased in game resource");

        UpdateText();

        EventData data = new EventData();

        data.AddInt("ResourceType", (int)resourceType);
        data.AddInt("Value", value);
        data.AddMonoBehaviour("Player", manager.owner);

        Grid.EventManager.SendEvent(Constants.GameEvent.ResourceChanged, data);
    }
Exemplo n.º 9
0
    public void CheckDeath(int source, bool forceDeath, bool waitForVFX)
    {
        //GameObject deathVFX;

        if (currentDeck.decktype == Constants.DeckType.SoulCrypt)
        {
            Debug.LogError(cardData.cardName + " is already dead, and was told to go to the soulcypt");
            return;
        }

        CardVisual causeOfDeath = Finder.FindCardByID(source);

        if (supportValue <= 0 || forceDeath)
        {
            if (photonView.isMine)
            {
                if (!waitForVFX)
                {
                    StartCoroutine(DisplayDeathEffect());
                    StartCoroutine(RemoveCardVisualFromField(this));
                }
                else
                {
                    Grid.EventManager.RegisterListener(Constants.GameEvent.VFXLanded, OnDeathVisual);
                }

                //if (deathEffect != "")
                //    deathVFX = PhotonNetwork.Instantiate(deathEffect, supportToken.incomingEffectLocation.position, Quaternion.identity, 0) as GameObject;
                //else {
                //    deathVFX = PhotonNetwork.Instantiate("VFX_NecroticFlash", supportToken.incomingEffectLocation.position, Quaternion.identity, 0) as GameObject;
                //}
            }

            Debug.Log(causeOfDeath.cardData.cardName + " has killed " + cardData.cardName);
            //currentDeck.RPCTransferCard(PhotonTargets.All, this, owner.activeCrypt.GetComponent<Deck>());
            currentDeck.TransferCard(photonView.viewID, owner.activeCrypt.GetComponent <Deck>().photonView.viewID);

            EventData data = new EventData();

            data.AddMonoBehaviour("DeadCard", this);
            data.AddMonoBehaviour("CauseOfDeath", causeOfDeath);

            Grid.EventManager.SendEvent(Constants.GameEvent.CreatureDied, data);
        }
    }
Exemplo n.º 10
0
    public void BroadcastAttacker(int id)
    {
        CardVisual attacker = Finder.FindCardByID(id);

        EventData data = new EventData();

        data.AddMonoBehaviour("Card", attacker);
        Grid.EventManager.SendEvent(Constants.GameEvent.CharacterAttacked, data);
    }
Exemplo n.º 11
0
    public void ActivateDomainAbility()
    {
        if (myDomainCard == null)
        {
            Debug.LogError("My card is null, dickhead");
            return;
        }



        Debug.Log(myDomainCard.cardData.cardName + "'s domain tile has been clicked");

        EventData data = new EventData();

        data.AddMonoBehaviour("Tile", this);
        data.AddMonoBehaviour("Card", myDomainCard);

        Grid.EventManager.SendEvent(Constants.GameEvent.UserActivatedDomainAbility, data);
    }
Exemplo n.º 12
0
    public void BroadcastTurnEnd(int playerID)
    {
        Player p = Finder.FindPlayerByID(playerID);

        EventData data = new EventData();

        data.AddMonoBehaviour("Player", p);

        Grid.EventManager.SendEvent(Constants.GameEvent.TurnEnded, data);
    }
Exemplo n.º 13
0
    public void BroadcastDefender(int id)
    {
        CardVisual defender = Finder.FindCardByID(id);

        //Debug.Log("Sending Defence Event");

        EventData data = new EventData();

        data.AddMonoBehaviour("Card", defender);
        Grid.EventManager.SendEvent(Constants.GameEvent.CharacterDefends, data);
    }
Exemplo n.º 14
0
    public void SetupResources(int textID, bool firstResource, int resourceTypeEnum, int current, int max, string name, int cap)
    {
        GameResource.ResourceType type = (GameResource.ResourceType)resourceTypeEnum;


        //Debug.Log(textID + " is the view id Sent");

        GameObject newTextGO = HUDRegistrar.FindHudElementByID(textID);

        if (newTextGO == null)
        {
            GameObject[] allHUD = GameObject.FindGameObjectsWithTag("HUD");

            foreach (GameObject go in allHUD)
            {
                if (go.GetPhotonView().viewID == textID)
                {
                    newTextGO = go;
                    break;
                }
            }
        }

        //Debug.Log(newTextGO);

        Text newText = newTextGO.GetComponent <Text>();

        if (firstResource)
        {
            GameResource essence = new GameResource(GameResource.ResourceType.Essence, 1, 1, "Essence", gameResourceDisplay, 10);

            gameResources.Add(essence);

            gameResourceDisplay.Initialize(this, essence, newText);
        }
        else
        {
            GameResource newResource = new GameResource(type, current, max, name, gameResourceDisplay, cap);

            gameResources.Add(newResource);

            gameResourceDisplay.AddNewResource(newResource, newText, false);



            EventData data = new EventData();
            data.AddInt("ResourceType", (int)type);
            data.AddInt("Value", current);
            data.AddMonoBehaviour("Player", this);

            Grid.EventManager.SendEvent(Constants.GameEvent.ResourceChanged, data);
        }
    }
Exemplo n.º 15
0
    public void RemoveCard(CardVisual card)
    {
        if (activeCards.Contains(card))
        {
            //card.currentDeck = null;
            //card.previousDeck = this;
            activeCards.Remove(card);
            //Debug.Log(card.gameObject.name + " has been removed from " + decktype.ToString());
        }

        //List<CardVisual> cardsOnboard = Finder.FindAllCardsInZone(DeckType.Battlefield);

        //foreach (CardVisual c in cardsOnboard) {
        //    Debug.Log(c.gameObject.name + " is on the battlefield");
        //}

        EventData data = new EventData();

        data.AddMonoBehaviour("Card", card);
        data.AddMonoBehaviour("Deck", this);

        Grid.EventManager.SendEvent(Constants.GameEvent.CardLeftZone, data);
    }
Exemplo n.º 16
0
    public void IncreaseMaximum(int value, bool temp = false)
    {
        if (resourceCap != 0 && maximumValue + value > resourceCap)
        {
            return;
        }

        maximumValue += value;

        EventData data = new EventData();

        data.AddInt("ResourceType", (int)resourceType);
        data.AddInt("Value", value);
        data.AddMonoBehaviour("Player", manager.owner);

        Grid.EventManager.SendEvent(Constants.GameEvent.ResourceChanged, data);


        UpdateText();
    }
Exemplo n.º 17
0
    public bool RemoveResource(int value)
    {
        if (currentValue - value < 0)
        {
            return(false);
        }
        else
        {
            currentValue -= value;
            UpdateText();

            EventData data = new EventData();
            data.AddInt("ResourceType", (int)resourceType);
            data.AddInt("Value", -value);
            data.AddMonoBehaviour("Player", manager.owner);

            Grid.EventManager.SendEvent(Constants.GameEvent.ResourceChanged, data);

            return(true);
        }
    }