Пример #1
0
 void Start()
 {
     anin             = GetComponent <Animator>();
     navAgent         = GetComponent <NavMeshAgent>();
     objective        = GameObject.FindGameObjectWithTag("Player").transform;
     isAlive          = true;
     primarySystemObj = GameObject.FindGameObjectWithTag("System");
     primaryScript    = primarySystemObj.GetComponent <PrimarySystem>();
     StartCoroutine(ManualCheck());
 }
Пример #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);
     }
 }
Пример #3
0
    private void Awake()
    {
        Cursor.visible = false;
        if (main != null && main != this)
        {
            Destroy(gameObject);
            return;
        }
        main         = this;
        playerScores = new int[2];

        manager  = World.DefaultGameObjectInjectionWorld.EntityManager;
        settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);
        //settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, new BlobAssetStore());
        ballEntityPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(ballPrefab, settings);

        oneSecond = new WaitForSeconds(1f);
        delay     = new WaitForSeconds(respawnDelay);

        StartCoroutine(CountdownAndSpawnBall());
    }
Пример #4
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>();
    }
Пример #5
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;
 }