Example #1
0
    private void SetGemColor()
    {
        int randomIndex = Random.Range(0, spriteList.Count);

        gameObject.GetComponent <SpriteRenderer>().sprite = spriteList[randomIndex];
        gemSprite = gameObject.GetComponent <SpriteRenderer>().sprite;

        switch (gemSprite.name)
        {
        case "purple_gem_animation_0":
            color = Enumerations.color.purple;
            break;

        case "green_gem_animation_0":
            color = Enumerations.color.green;
            break;

        case "red_gem_animation_0":
            color = Enumerations.color.red;
            break;

        case "teal_gem_animation_0":
            color = Enumerations.color.teal;
            break;
        }
    }
Example #2
0
 public void SetDoorColor(Enumerations.color color)
 {
     this.color = color;
     SetChildColor();
     SetDoorSprite();
     SetDoorAnimator();
 }
Example #3
0
    public Enumerations.color ConvertGemColor(Enumerations.color inputColor)
    {
        Enumerations.color outputColor = Enumerations.color.red;

        switch (inputColor)
        {
        case Enumerations.color.red:
            outputColor = Enumerations.color.green;
            break;

        case Enumerations.color.green:
            outputColor = Enumerations.color.purple;
            break;

        case Enumerations.color.purple:
            outputColor = Enumerations.color.teal;
            break;

        case Enumerations.color.teal:
            outputColor = Enumerations.color.red;
            break;
        }

        return(outputColor);
    }
Example #4
0
    private void RandomizeDoorColors()
    {
        Door[] doorArray = FindObjectsOfType <Door>();

        foreach (var item in doorArray)
        {
            if (item.tag == "Door")
            {
                int randomIndex          = Random.Range(0, 4);
                Enumerations.color color = Enumerations.color.red;

                switch (randomIndex)
                {
                case 0:
                    color = Enumerations.color.purple;
                    break;

                case 1:
                    color = Enumerations.color.green;
                    break;

                case 2:
                    color = Enumerations.color.red;
                    break;

                case 3:
                    color = Enumerations.color.teal;
                    break;
                }
                item.SetDoorColor(color);
            }
        }
    }
Example #5
0
 public void UpdateGemButtons()
 {
     foreach (var item in gemButtons)
     {
         Enumerations.color color = item.GetButtonColor();
         item.UpdateNumberOfGems(gemInventory[color]);
     }
 }
Example #6
0
 public void OpenDoor(Enumerations.color color)
 {
     if (nearDoor && doorColor == color)
     {
         inventory.UseGems(color, 1);
         Destroy(doorObject);
         nearDoor = false;
     }
 }
Example #7
0
 public void OpenDoor(Enumerations.color color)
 {
     if (nearDoor && doorColor == color)
     {
         inventory.UseGems(color, 1);
         doorObject.GetComponent <Destroyer>().Disappear();
         nearDoor = false;
     }
 }
Example #8
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Door")
     {
         nearDoor       = true;
         doorNearPlayer = collision.gameObject.GetComponent <Door>();
         doorColor      = doorNearPlayer.GetDoorColor();
         doorObject     = collision.gameObject;
     }
 }
Example #9
0
 private void UpdateGemButton(Enumerations.color color)
 {
     foreach (var item in gemButtons)
     {
         if (item.GetButtonColor() == color)
         {
             item.UpdateNumberOfGems(gemInventory[color]);
         }
     }
 }
Example #10
0
    private string GetSpriteName(Enumerations.color color)
    {
        string spriteName = "";

        if (doorType == Enumerations.doorType.front)
        {
            switch (color)
            {
            case Enumerations.color.purple:
                spriteName = "portal_purple_animation_0";
                break;

            case Enumerations.color.green:
                spriteName = "portal_green_animation_0";
                break;

            case Enumerations.color.red:
                spriteName = "portal_red_animation_0";
                break;

            case Enumerations.color.teal:
                spriteName = "portal_teal_animation_0";
                break;
            }
        }
        else if (doorType == Enumerations.doorType.side)
        {
            switch (color)
            {
            case Enumerations.color.purple:
                spriteName = "portals_top_24";
                break;

            case Enumerations.color.green:
                spriteName = "portals_top_20";
                break;

            case Enumerations.color.red:
                spriteName = "portals_top_28";
                break;

            case Enumerations.color.teal:
                spriteName = "portals_top_16";
                break;
            }
        }
        return(spriteName);
    }
Example #11
0
    private void SetDoorColor()
    {
        switch (doorSprite.name)
        {
        case "purpleDoor":
            color = Enumerations.color.purple;
            break;

        case "greenDoor":
            color = Enumerations.color.green;
            break;

        case "redDoor":
            color = Enumerations.color.red;
            break;

        case "yellowDoor":
            color = Enumerations.color.yellow;
            break;
        }
    }
Example #12
0
    private void SetGemColor()
    {
        switch (gemSprite.name)
        {
        case "purpleGem":
            color = Enumerations.color.purple;
            break;

        case "greenGem":
            color = Enumerations.color.green;
            break;

        case "redGem":
            color = Enumerations.color.red;
            break;

        case "yellowGem":
            color = Enumerations.color.yellow;
            break;
        }
    }
Example #13
0
    public void OnPointerDown(PointerEventData eventData)
    {
        isConverterActive = gemConverter.converterActive;

        if (isConverterActive)
        {
            int manaCost = inventory.GetManaCost(color);
            mana.AdjustMana(-manaCost);
            Enumerations.color convertedColor = gemConverter.ConvertGemColor(color);
            inventory.UseGems(color, 1);
            inventory.AddGems(convertedColor, 1);
        }
        else if (!isConverterActive)
        {
            //check if number of gems is greater than 0
            if (currentGemNumber > 0)
            {
                wizard.OpenDoor(color);
            }
        }
    }
Example #14
0
 public int GetManaCost(Enumerations.color color)
 {
     return(manaCostDictionary[color]);
 }
Example #15
0
 public void UseGems(Enumerations.color color, int number)
 {
     gemInventory[color] -= number;
     UpdateGemButton(color);
 }