Exemplo n.º 1
0
    public static CardDefinitionType GetCardDefinitionType(CardCategory category, PickupEffect effect1)
    {
        switch (category)
        {
        case CardCategory.Creature:
            switch (effect1)
            {
            case PickupEffect.None:
                return(CardDefinitionType.SmallPlayerCreature);

            case PickupEffect.Damage:
                return(CardDefinitionType.PlayerCreatureDamage);
            }
            break;

        case CardCategory.InstantSpell:
            switch (effect1)
            {
            case PickupEffect.Damage:
                return(CardDefinitionType.Fireball);
            }
            break;
        }

        Debug.LogError("Error: couldn't find CardDefinitionType for combination " + category + " - " + effect1);
        return(CardDefinitionType.None);
    }
Exemplo n.º 2
0
    protected override void Start()
    {
        base.Start();
        int enumLength = System.Enum.GetNames(typeof(PickupEffect)).Length;

        BlockEffect = (PickupEffect)UnityEngine.Random.Range(0, enumLength);
        score       = ConfigurationUtils.PickupBlockPoints;
    }
Exemplo n.º 3
0
    // Use this for initialization
    public override void Start()
    {
        int enumLength = System.Enum.GetNames(typeof(PickupEffect)).Length;

        Effect = (PickupEffect)UnityEngine.Random.Range(0, enumLength);
        point  = ConfigurationUtils.PickUpBlockPoints;
        base.Start();
    }
 // Update is called once per frame
 void Update()
 {
     if (gameObject.CompareTag("Freeze"))
     {
         pickUpEffect = PickupEffect.Freezer;
     }
     else if (gameObject.CompareTag("Speed"))
     {
         pickUpEffect = PickupEffect.Speedup;
     }
 }
Exemplo n.º 5
0
 public PickupEffectInfo GetPickupEffectInfo(PickupEffect effect)
 {
     for (int i = 0; i < pickupEffectsInfo.Count; i++)
     {
         if (pickupEffectsInfo[i].effect == effect)
         {
             return(pickupEffectsInfo[i]);
         }
     }
     Debug.LogError("Error: couldn't find pickup effect info for " + effect + " in card definitions library.");
     return(null);
 }
Exemplo n.º 6
0
    public void SetupSprite(PickupEffect effect)
    {
        SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();

        if (effect == PickupEffect.Freezer)
        {
            spriteRenderer.sprite = freezerBlockSprite;
        }
        else if (effect == PickupEffect.Speedup)
        {
            spriteRenderer.sprite = speedUpBlockSprite;
        }
    }
Exemplo n.º 7
0
    // Start is called before the first frame update
    protected override void Start()
    {
        int pickuptype = Random.Range(0, 2);

        if (pickuptype == 0)
        {
            Effect = PickupEffect.Freezer;
        }
        else
        {
            Effect = PickupEffect.Speedup;
        }
        points = ConfigurationUtils.PickupBlockPoints;
        base.Start();
    }
Exemplo n.º 8
0
    // Start is called before the first frame update
    override protected void Start()
    {
        //for choise what type of block
        spriteRenderer        = GetComponent <SpriteRenderer>();
        effect                = (PickupEffect)Random.Range(0, 2);
        spriteRenderer.sprite = blockSprite[(int)effect];

        points = ConfigurationUtils.PointsPickup;

        base.Start();

        //timers init

        EventManager.AddFreezerInvoker(this);
        EventManager.AddSpeddyInvoker(this);
    }
Exemplo n.º 9
0
    // Start is called before the first frame update
    override protected void Start()
    {
        base.Start();
        blockValue = ConfigurationUtils.PickUpBlockPoints;

        SpriteRenderer sr = GetComponent <SpriteRenderer>();

        int num = Random.Range(0, 2);

        if (num == 0)
        {
            sr.sprite = freezeBlock; PickUpType = PickupEffect.Freezer;
        }
        else
        {
            sr.sprite = speedUpBlock; PickUpType = PickupEffect.Speedup;
        }
    }
Exemplo n.º 10
0
 public void ReapReward()
 {
     GlobalGameManager.Instance.CoinsAmount += card.cardDefinition.goldReward;
     PickupDefinition earnedPickup = null;
     if (GlobalGameManager.Instance.tutoManager.CurrentTutoStep == TutoManager.TutoStep.ToCardCrafting &&
         GlobalGameManager.Instance.pickupCollection.GetCurrentPickupsAmount() == 0)
     {
         earnedPickup = new PickupCategoryDefinition(CardCategory.Creature);
     }
     else
     {
         for (int i = 0; i < 3; i++)
         {
             if (Random.Range(0f, 1f) < 0.6f)
             {
                 if (Random.Range(0f, 1f) < 0.3f)
                 {
                     System.Array categories = System.Enum.GetValues(typeof(CardCategory));
                     int categoriesAmount = categories.Length;
                     CardCategory category = CardCategory.None;
                     while (category == CardCategory.None)
                     {
                         category = (CardCategory)categories.GetValue(Random.Range(0, categoriesAmount));
                     }
                     earnedPickup = new PickupCategoryDefinition(category);
                 }
                 else
                 {
                     System.Array effects = System.Enum.GetValues(typeof(PickupEffect));
                     int effectsAmount = effects.Length;
                     PickupEffect effect = PickupEffect.None;
                     while (effect == PickupEffect.None)
                     {
                         effect = (PickupEffect)effects.GetValue(Random.Range(0, effectsAmount));
                     }
                     earnedPickup = new PickupEffectDefinition(effect);
                 }
             }
         }
     }
     if(earnedPickup != null)
         GlobalGameManager.Instance.pickupCollection.EarnPickup(earnedPickup);
 }
Exemplo n.º 11
0
    // Start is called before the first frame update
    override protected void Start()
    {
        //check the effect of this block
        effectThisBlock = GetComponent <Block>().Effect;

        //set the effects duration
        freezeEffectDuration  = ConfigurationUtils.FreezerEffectDuration;
        speedupEffectDuration = ConfigurationUtils.SpeedupEffectDuration;

        //Event handling
        freezerEffectActivated = new FreezerEffectActivated();
        speedupEffectActivated = new SpeedupEffectActivated();

        //add effect invoker if this block is a freezer/speedup
        if (effectThisBlock == PickupEffect.Freezer)
        {
            EventManager.AddFreezeInvoker(this);
        }
        else if (effectThisBlock == PickupEffect.Speedup)
        {
            EventManager.AddSpeedupInvoker(this);
        }

        // Define data based on component attached (speedup or freezer)
        // Not the best approach but it is used to minimize major changes

        if (GetComponent <Block_Speedup>() != null)
        {
            destroyPoints   = ConfigurationUtils.BlockSpeedupPoints;
            percentageSpawn = ConfigurationUtils.BlockSpeedupProbability;
            effect          = PickupEffect.Speedup;
        }
        else if (GetComponent <Block_Freezer>() != null)
        {
            destroyPoints   = ConfigurationUtils.BlockFreezerPoints;
            percentageSpawn = ConfigurationUtils.BlockFreezerProbability;
            effect          = PickupEffect.Freezer;
        }

        base.Start();
    }
Exemplo n.º 12
0
    private void RandomPickupEffect()
    {
        for (int i = 0; i < ConfigurationUtils.FreezerBlockSpawnProbability; i++)
        {
            pickupBlocks.Add(PickupEffect.Freezer);
        }

        for (int i = 0; i < ConfigurationUtils.SpeedupBlockSpawnProbability; i++)
        {
            pickupBlocks.Add(PickupEffect.Speedup);
        }

        int randomIndex = 0;

        while (pickupBlocks.Count > 0)
        {
            randomIndex = Random.Range(0, pickupBlocks.Count);
            randomPickupBlocks.Add(pickupBlocks[randomIndex]);
            pickupBlocks.RemoveAt(randomIndex);
        }

        pickupEffect = randomPickupBlocks[Random.Range(0, randomPickupBlocks.Count)];
    }
Exemplo n.º 13
0
    private void RandomPickupEffect()
    {
        for (int i = 0; i < 15f; i++)
        {
            pickupBlocks.Add(PickupEffect.Freezer);
        }

        for (int i = 0; i < 20f; i++)
        {
            pickupBlocks.Add(PickupEffect.Speedup);
        }

        int randomIndex = 0;

        while (pickupBlocks.Count > 0)
        {
            randomIndex = Random.Range(0, pickupBlocks.Count);
            randomPickupBlocks.Add(pickupBlocks[randomIndex]);
            pickupBlocks.RemoveAt(randomIndex);
        }

        pickupEffect = randomPickupBlocks[Random.Range(0, randomPickupBlocks.Count)];
    }
Exemplo n.º 14
0
 public void RemoveActiveEffect(PickupEffect pEffect)
 {
     m_pCurrentActivePickupEffects.Remove(pEffect);
 }
Exemplo n.º 15
0
 public void GiveActiveEffect(PickupEffect pEffect)
 {
     Assert.IsFalse(m_pCurrentActivePickupEffects.Contains(pEffect), "An effect (" + pEffect.name + ") has been added to the effects list but was already in it. This is not supported behaviour, please fix or change the code to allow it");
     m_pCurrentActivePickupEffects.Add(pEffect);
 }
Exemplo n.º 16
0
 public bool HasActiveEffect(PickupEffect pEffect)
 {
     return(m_pCurrentActivePickupEffects.Contains(pEffect));
 }
Exemplo n.º 17
0
 public PickupEffectInfo(PickupEffect _effect)
 {
     name   = _effect.ToString();
     effect = _effect;
 }
Exemplo n.º 18
0
 public PickupEffectDefinition(PickupEffect _effect)
 {
     effect = _effect;
 }
Exemplo n.º 19
0
    //TargettingType GetTargetingType()
    //{
    //    switch (cardBase)
    //    {
    //        case CardDefinitionType.Fireball:
    //            return TargettingType.AnySpot;

    //        default:
    //            Debug.LogError("Error: card base " + cardBase + " isn't handled in GetTargetingType.");
    //            return TargettingType.AnySpot;
    //    }
    //}

    public bool AddBonus(PickupDefinition pickup, bool apply = false)
    {
        if (pickup.type == PickupType.Category)
        {
            CardCategory pickupCategory = (pickup as PickupCategoryDefinition).category;
            switch (pickupCategory)
            {
            // Applying a Creature pickup
            case CardCategory.Creature:
                if (cardDefinition.cardCategory == CardCategory.Creature)
                {
                    if (apply)
                    {
                        healthBonus += 1;
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }

            // Applying an InstantSpell pickup
            case CardCategory.InstantSpell:
                if (cardDefinition.cardCategory == CardCategory.Creature)
                {
                    if (apply)
                    {
                        movesBonus += 1;
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }

            default:
                Debug.LogError("Pickup category " + pickupCategory + " not handled in AddBonus");
                return(false);
            }
        }
        else if (pickup.type == PickupType.Effect)
        {
            PickupEffect pickupEffect = (pickup as PickupEffectDefinition).effect;
            switch (pickupEffect)
            {
            // Applying a Creature pickup
            case PickupEffect.Damage:
                if (cardDefinition.cardCategory == CardCategory.Creature)
                {
                    if (apply)
                    {
                        damageBonus += 1;
                    }
                    return(true);
                }
                else
                {
                    switch (cardDefinition.cardType)
                    {
                    case CardDefinitionType.Fireball:
                        if (apply)
                        {
                            damageBonus += 1;
                        }
                        return(true);

                    default:
                        Debug.LogError("Pickup effect " + pickupEffect + " not handled for card type " + cardDefinition.cardType + " in AddBonus");
                        return(false);
                    }
                }

            default:
                Debug.LogError("Pickup effect " + pickupEffect + " not handled in AddBonus");
                return(false);
            }
        }
        else
        {
            Debug.LogError("Wtf, what this pickup of type " + pickup.type + "?!");
        }
        return(false);
    }