Exemple #1
0
    void Start()
    {
        // If instance already exists
        if (instance != null && instance != this)
        {
            // Destroy it
            Destroy(gameObject);
        }
        else
        {
            // Set this to instance
            instance = this;
        }

        // Set wepaon manager to the player's weapon manager (script atatched to player) & consumables manager
        weaponManager     = GetComponent <WeaponManager>();
        consumableManager = GetComponent <ConsumableManager>();
        offhandManager    = GetComponent <OffhandManager>();
        helmetManager     = GetComponent <HelmetManager>();
        chestplateManager = GetComponent <ChestplateManager>();
        platelegsManager  = GetComponent <PlatelegsManager>();
        bootsManager      = GetComponent <BootsManager>();
        AddItemToInventory("sword");

        //AddItemToInventory("testConsumable");
    }
Exemple #2
0
    public void StartCooking(GameObject consumable)
    {
        cooking   = true;
        cookStart = Time.time;
        Color c = myImage.color;

        c.a           = 0.5f;
        myImage.color = c;
        //myImage.sprite = busyImage;
        ConsumableManager consumableManager = (ConsumableManager)consumable.GetComponent(typeof(ConsumableManager));

        cookingConsumableType = consumableManager.type;
        if (cookingConsumableType == ConsumableManager.ConsumableTypeEnum.Worm)
        {
            SetSick();
        }
    }
 private void Awake()
 {
     instance = this;
 }
 void Awake()
 {
     instance = this;
 }
 public ConsumableController()
 {
     _consumableMan = new ConsumableManager();
 }
Exemple #6
0
    public void moveConsumable(GameObject consumable)
    {
        if (consumable == null)
        {
            return;
        }
        float             canvasHeight      = canvasRectTransform.rect.height;
        float             moveY             = -1 * (canvasHeight / 300);
        ConsumableManager consumableManager = (ConsumableManager)consumable.GetComponent(typeof(ConsumableManager));

        if (consumableManager.type == ConsumableManager.ConsumableTypeEnum.Worm)
        {
            moveY = -1.43f * (canvasHeight / 300);
        }
        consumable.transform.Translate(new Vector3(0, moveY, 0));
        List <GameObject> overlappingCooks = getOverlappingCooks(consumable);

        if (overlappingCooks.Count > 0)
        {
            //Debug.Log("overlapping!");
            //Debug.Log(consumable.transform.position.y);
            GameObject  cook        = overlappingCooks[0];
            CookManager cookManager = (CookManager)cook.GetComponent(typeof(CookManager));
            if (cookManager.IsCooking() == false)
            {
                playerScore++;
                clearProgress++;
                scoreTextCorner.text = playerScore.ToString();
                //scoreText.text = playerScore.ToString();
                cookManager.StartCooking(consumable);
                destroyConsumable(consumable);
                CheckNewCook();
                if (clearProgress >= cookedConsumablesForClear)
                {
                    if (playerScore == cookedConsumablesForClear)
                    {
                        gameInProgress = false;
                        Image unlockedImage          = unlockOverlay.transform.Find("Popup").transform.Find("UnlockedImage").GetComponent <Image>();
                        Text  text                   = unlockOverlay.transform.Find("Popup").transform.Find("Text").GetComponent <Text>();
                        Text  unlockedSpecialization = unlockOverlay.transform.Find("Popup").transform.Find("UnlockedSpecialization").GetComponent <Text>();
                        unlockedImage.sprite        = clearSprite;
                        text.text                   = "Clear button unlocked !";
                        unlockedSpecialization.text = "Use this button to destroy all fruits !";
                        unlockOverlay.SetActive(true);
                        animUnlockPopup.SetTrigger("triggerUnlock");
                    }
                    clearPanel.SetActive(false);
                    clearButton.SetActive(true);
                }
            }
        }

        if (consumable.transform.position.y < 0)
        {
            if (consumableManager.type == ConsumableManager.ConsumableTypeEnum.Worm)
            {
                rottenConsumables = rottenConsumables - 2;
                if (rottenConsumables < 0)
                {
                    rottenConsumables = 0;
                }
                Image backgroundImage = canvas.transform.Find("Image").GetComponent <Image>();
                Color c = backgroundImage.color;
                c.g = 255 - (25 * rottenConsumables);
                c.b = 255 - (25 * rottenConsumables);
                backgroundImage.color = new Color32(255, (byte)c.g, (byte)c.b, 255);
            }
            else
            {
                anim.SetTrigger("TriggerTrash");
                rottenConsumables++;
                Image backgroundImage = canvas.transform.Find("Image").GetComponent <Image>();
                Color c = backgroundImage.color;
                c.g = 255 - (25 * rottenConsumables);
                c.b = 255 - (25 * rottenConsumables);
                backgroundImage.color = new Color32(255, (byte)c.g, (byte)c.b, 255);
                if (rottenConsumables > rottenConsumablesForLose)
                {
                    gameInProgress = false;
                    gameOverOverlay.SetActive(true);
                    animGameOverPopup.SetTrigger("triggerGameOver");
                    scoreTextEnd.text = playerScore.ToString();
                }
            }
            destroyConsumable(consumable);
        }
    }