public SecondarySystem SelectSecondarySystem()
 {
     drawIndex++;
     currentSecondarySystem = secondarySystems[Random.Range(0, secondarySystems.Count)];
     secondarySystems.Remove(currentSecondarySystem);
     currentSecondarySystem.drawIndex = drawIndex;
     if (packWithOneSecondarySystem)
     {
         drawIndex++;
     }
     return(currentSecondarySystem);
 }
Exemple #2
0
 void CleanPreviousAssociatedObjects()
 {
     if (currentAssociatedLever)
     {
         currentAssociatedLever.currentRessource = RessourcesType.none;
         currentAssociatedLever = null;
     }
     if (currentAssociatedPrimarySystem)
     {
         currentAssociatedPrimarySystem.filling = false;
         currentAssociatedPrimarySystem         = null;
     }
     if (currentAssociatedSecondarySystem)
     {
         currentAssociatedSecondarySystem.filling = false;
         currentAssociatedSecondarySystem         = null;
         IsSecondarySystemFilling(false);
     }
 }
    void StartActivity()
    {
        if (allSecondarySystems.Count > 0)
        {
            int selectedPack = Random.Range(0, allSecondarySystems.Count);
            if (lastPack != null)
            {
                if (lastPack.secondarySystems.Count > 0)
                {
                    allSecondarySystems.Add(lastPack);
                }
            }
            SecondarySystem selectedSecondarySystem = allSecondarySystems[selectedPack].SelectSecondarySystem();
            selectedSecondarySystem.associatedPack = allSecondarySystems[selectedPack];
            lastPack = allSecondarySystems[selectedPack];
            allSecondarySystems.RemoveAt(selectedPack);
            selectedSecondarySystem.animator.SetBool("OnActivity", true);
            if (selectedSecondarySystem.memberAnimator)
            {
                selectedSecondarySystem.memberAnimator.speed = 1f;
            }
            switch (GetRandomType())
            {
            case LeverScript.RessourcesType.energy:
                selectedSecondarySystem.currentEnergy = 0f;
                selectedSecondarySystem.energyGauge.SetActive(true);
                selectedSecondarySystem.energyNeeded = true;
                break;

            case LeverScript.RessourcesType.oxygen:
                selectedSecondarySystem.currentOxygen = 0f;
                selectedSecondarySystem.oxygenGauge.SetActive(true);
                selectedSecondarySystem.oxygenNeeded = true;
                break;
            }
            activesSecondarySystems++;
            HintSecondarySystemManager.instance.activeSecondarySystems.Add(selectedSecondarySystem);
            TimerSecondarySystem timerObject = Instantiate(GameManager.instance.UI_timerSS, UI_Manager.instance.transform).GetComponent <TimerSecondarySystem>();
            timerObject.associatedSystem = selectedSecondarySystem;
            SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.SecondarySystemPop, ssManagerSource);
            CharacterController2D.instance.animatorFace.SetTrigger("Choc");
        }
    }
 public void LaunchSpecificSS(SecondarySystem specificSecondarySystem, Pack associatedPack, LeverScript.RessourcesType ressource = LeverScript.RessourcesType.energy, bool showTimer = true)
 {
     if (lastPack != null)
     {
         if (lastPack.secondarySystems.Count > 0)
         {
             allSecondarySystems.Add(lastPack);
         }
     }
     specificSecondarySystem.associatedPack = associatedPack;
     lastPack = associatedPack;
     allSecondarySystems.Remove(associatedPack);
     specificSecondarySystem.animator.SetBool("OnActivity", true);
     if (specificSecondarySystem.memberAnimator)
     {
         specificSecondarySystem.memberAnimator.speed = 1f;
     }
     if (ressource == LeverScript.RessourcesType.energy)
     {
         specificSecondarySystem.currentEnergy = 0f;
         specificSecondarySystem.energyGauge.SetActive(true);
         specificSecondarySystem.energyNeeded = true;
     }
     else
     {
         specificSecondarySystem.currentOxygen = 0f;
         specificSecondarySystem.oxygenGauge.SetActive(true);
         specificSecondarySystem.oxygenNeeded = true;
     }
     activesSecondarySystems++;
     HintSecondarySystemManager.instance.activeSecondarySystems.Add(specificSecondarySystem);
     if (showTimer)
     {
         TimerSecondarySystem timerObject = Instantiate(GameManager.instance.UI_timerSS, UI_Manager.instance.transform).GetComponent <TimerSecondarySystem>();
         timerObject.associatedSystem = specificSecondarySystem;
     }
     SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.SecondarySystemPop, ssManagerSource);
 }
Exemple #5
0
    private void Start()
    {
        if (doubleEntry)
        {
            if (endObject.GetComponent <LeverScript>())
            {
                currentAssociatedLever = endObject.GetComponent <LeverScript>();
            }
            else if (endObject.GetComponent <PrimarySystem>())
            {
                if (endObject.GetComponent <LungsManager>())
                {
                    currentAssociatedPrimarySystem = endObject.GetComponent <LungsManager>();
                }
                else
                {
                    currentAssociatedPrimarySystem = endObject.GetComponent <StomachManager>();
                }
            }
            else if (endObject.GetComponent <SecondarySystem>())
            {
                currentAssociatedSecondarySystem = endObject.GetComponent <SecondarySystem>();
            }
            else
            {
                Debug.LogError("There is no correct object associated at the end of this lever : " + gameObject.name + " current end object : " + endObject);
            }
        }
        for (int i = 0; i < pipes.Length; i++)
        {
            pipes[i].shapeRenderer   = pipes[i].pipe.GetComponent <SpriteShapeRenderer>();
            pipes[i].shapeController = pipes[i].pipe.GetComponent <SpriteShapeController>();
        }

        UpdatePipe();

        foreach (LeakZone item in pipes[0].pipe.GetComponentsInChildren <LeakZone>())
        {
            pipe0LeaksZones.Add(item);
        }
        foreach (LeakZone item in pipes[1].pipe.GetComponentsInChildren <LeakZone>())
        {
            pipe1LeaksZones.Add(item);
        }

        if (pipe0LeaksZones.Count != 0)
        {
            allLeaksZones[0] = pipe0LeaksZones;
        }
        if (pipe1LeaksZones.Count != 0)
        {
            allLeaksZones[1] = pipe1LeaksZones;
        }
        if (allLeaksZones[0] != null || allLeaksZones[1] != null)
        {
            LeaksManager.instance.leversWithLeaksZones.Add(this);
        }

        foreach (GameObject item in associatedObjects)
        {
            if (item.GetComponent <LeverScript>())
            {
                item.GetComponent <LeverScript>().previousLever = this;
            }
            if (item.GetComponent <SecondarySystem>())
            {
                item.GetComponent <SecondarySystem>().associatedLever = this;
            }
        }
        if (endObject)
        {
            if (endObject.GetComponent <LeverScript>())
            {
                endObject.GetComponent <LeverScript>().previousLever = this;
            }
            if (endObject.GetComponent <SecondarySystem>())
            {
                endObject.GetComponent <SecondarySystem>().associatedLever = this;
            }
        }
        anim = GetComponent <Animator>();
    }
Exemple #6
0
 void UpdatePipe()
 {
     if (doubleEntry)
     {
         UpdateDoubleEntry();
         return;
     }
     CleanPreviousAssociatedObjects();
     if (associatedObjects[currentPipe].GetComponent <LeverScript>())
     {
         currentAssociatedLever = associatedObjects[currentPipe].GetComponent <LeverScript>();
         currentAssociatedLever.currentRessource = currentRessource;
     }
     else if (associatedObjects[currentPipe].GetComponent <PrimarySystem>())
     {
         if (initialPipes)
         {
             if (associatedObjects[currentPipe].GetComponent <LungsManager>())
             {
                 currentRessource = RessourcesType.oxygen;
             }
             else
             {
                 currentRessource = RessourcesType.energy;
             }
             currentAssociatedPrimarySystem         = associatedObjects[currentPipe].GetComponent <PrimarySystem>();
             currentAssociatedPrimarySystem.filling = true;
         }
         else
         {
             if (associatedObjects[currentPipe].GetComponent <LungsManager>())
             {
                 if (currentRessource == RessourcesType.oxygen)
                 {
                     currentAssociatedPrimarySystem         = associatedObjects[currentPipe].GetComponent <PrimarySystem>();
                     currentAssociatedPrimarySystem.filling = true;
                 }
                 else
                 {
                     //WRONG RESSOURCE
                 }
             }
             else
             {
                 if (currentRessource == RessourcesType.energy)
                 {
                     currentAssociatedPrimarySystem         = associatedObjects[currentPipe].GetComponent <PrimarySystem>();
                     currentAssociatedPrimarySystem.filling = true;
                 }
                 else
                 {
                     //WRONG RESSOURCE
                 }
             }
         }
     }
     else if (associatedObjects[currentPipe].GetComponent <SecondarySystem>())
     {
         currentAssociatedSecondarySystem = associatedObjects[currentPipe].GetComponent <SecondarySystem>();
         if (currentAssociatedSecondarySystem.energyNeeded)
         {
             if (currentRessource == RessourcesType.energy)
             {
                 currentAssociatedSecondarySystem.filling = true;
                 SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.StartFillingSecondarySystem, currentAssociatedSecondarySystem.audioSource);
                 IsSecondarySystemFilling(true);
             }
             else
             {
                 //WRONG RESSOURCE
             }
         }
         else if (currentAssociatedSecondarySystem.oxygenNeeded)
         {
             if (currentRessource == RessourcesType.oxygen)
             {
                 currentAssociatedSecondarySystem.filling = true;
                 SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.StartFillingSecondarySystem, currentAssociatedSecondarySystem.audioSource);
                 IsSecondarySystemFilling(true);
             }
             else
             {
                 //WRONG RESSOURCE
             }
         }
     }
     else
     {
         Debug.LogError("There is no correct object associated to this pipe : " + pipes[currentPipe] + " actual object : " + associatedObjects[currentPipe]);
     }
     UpdatePipesDisplay();
     lastFrameRessource = currentRessource;
 }