예제 #1
0
파일: PointMgr.cs 프로젝트: LucasMoDz/GGJ18
    public void DecreasePoint()
    {
        Color defaultcolor = gainedPoint.color;

        gainedPoint.text  = "-50";
        gainedPoint.color = Color.red;
        gainedPoint.gameObject.SetActive(true);
        Color mycolod = pointsTxt.color;

        //pointsTxt.color = Color.red;


        UtilitiesGen.CallMethod(1, () =>
        {
            gainedPoint.color = defaultcolor;
            gainedPoint.gameObject.SetActive(false);
            pointsTxt.color = mycolod;

            currentPoints -= 50;

            if (currentPoints < 0)
            {
                currentPoints = 0;
            }
        });
    }
예제 #2
0
파일: PointMgr.cs 프로젝트: LucasMoDz/GGJ18
    private void Awake()
    {
        gainedPoint.gameObject.SetActive(false);
        int recordSaved = UtilitiesGen.ReadingByFile <int>(FileName.PlayerData);

        record = recordSaved;
    }
예제 #3
0
    private void Awake()
    {
        canvasGroup = this.GetComponent <CanvasGroup>();

        retry.onClick.AddListener(() => { fadeImage.GetComponent <MainMenu>().LoadLevel(1); });
        exit.onClick.AddListener(() => { fadeImage.GetComponent <MainMenu>().LoadLevel(0); });

        if (canvasGroup == null)
        {
            Debug.LogError("Public reference on ManagerGameOver is null, fix it\n");
        }
        else
        {
            GameOverEvent.OpenPanel += () =>
            {
                EventManager.Invoke(SoundManagerTopics.PlayEffect, AudioClipName.Explosion01);

                UtilitiesGen.CallMethod(2, () => { UtilitiesUI.ObjectActivation(canvasGroup, ConstantValues.FADEINTIME); });
                PointMgr pointClass = FindObjectOfType <PointMgr>();

                if (lastScore == null)
                {
                    Debug.Log("last score null!!");
                }
                else
                {
                    lastScore.text = pointClass.currentPoints.ToString();
                    Debug.Log("last score SETTATO!!");
                }

                if (pointClass.record < pointClass.currentPoints)
                {
                    pointClass.record = pointClass.currentPoints;
                    UtilitiesGen.WritingToFile(FileName.PlayerData, pointClass.record);
                }

                if (bestScore == null)
                {
                    Debug.Log("best score null!!");
                }
                else
                {
                    bestScore.text = pointClass.record.ToString();
                    Debug.Log("best score SETTATO!!");
                }

                //SpaceShipHandler spaceShip = FindObjectOfType<SpaceShipHandler>();
                //spaceShip.reset();
                //spaceShip.earthObject.GetComponent<EarthEnergyHandler>().reset();
            };
        }
    }
예제 #4
0
    /// <summary> Print on console many informations of coroutine overloading. </summary>
    /// <param name="_gameObject"> GameObject to be checked. </param>
    public static void SearchConflict(GameObject _gameObject)
    {
        #if UNITY_EDITOR
        Transform[] allGameObjects = Resources.FindObjectsOfTypeAll(typeof(Transform)) as Transform[];

        foreach (var obj in allGameObjects)
        {
            if (obj.GetInstanceID().Equals(_gameObject.transform.GetInstanceID()))
            {
                string debugMessage = "More than one coroutine are running on '" + obj.transform.name + "'.\nPath: ";

                StackFrame stackFrame        = null;
                int        secondToLastIndex = 0;

                for (int i = 3; i < 100; i++)
                {
                    stackFrame        = new StackFrame(i);
                    secondToLastIndex = i;

                    debugMessage += UtilitiesGen.GetStringFromStartToChar(stackFrame.GetMethod().DeclaringType.ToString(), '+') + " > ";

                    if (IsSecondToLastCall(stackFrame))
                    {
                        break;
                    }
                }

                string functionCalled = stackFrame.GetMethod().Name;
                stackFrame = new StackFrame(secondToLastIndex + 1);

                if (stackFrame.GetMethod().Name.Equals("MoveNext"))
                {
                    debugMessage += UtilitiesGen.GetStringFromStartToChar(stackFrame.GetMethod().DeclaringType.ToString(), '+') + " > IEnumerator " + UtilitiesGen.GetStringFromFirstCharToSecond(stackFrame.GetMethod().DeclaringType.ToString(), '<', '>') + " > ";
                }
                else
                {
                    debugMessage += UtilitiesGen.GetStringFromStartToChar(stackFrame.GetMethod().DeclaringType.ToString(), '+') + "  > void " + stackFrame.GetMethod().Name + " > ";
                }

                debugMessage += functionCalled;
                //Debug.LogError(debugMessage);
                break;
            }
        }
        #endif
    }
예제 #5
0
파일: PointMgr.cs 프로젝트: LucasMoDz/GGJ18
    public void spaceShipRight(float timeLeftPerc)
    {
        gainedPoint.color = Color.green;
        gainedPoint.gameObject.SetActive(true);
        gainedPoint.text = "+" + (spaceShipMultiplier + (int)(timeLeftPerc * 100f));
        Color mycolod = pointsTxt.color;

        //pointsTxt.color = Color.green;
        UtilitiesGen.CallMethod(1f, () =>
        {
            gainedPoint.color = mycolod;

            gainedPoint.gameObject.SetActive(false);
            pointsTxt.color = mycolod;

            currentPoints += (spaceShipMultiplier + (int)(timeLeftPerc * 100f));
            spaceShipMultiplier++;
        });
    }
예제 #6
0
    public void GamePhase()
    {
        // Randomize race
        lastRace = Random.Range(0, 3);

        spaceShip.SetCurrentSprite(lastRace);



        // Set lastMeaning variable (that will be called by PhraseGenerator)
        var meanings = UtilitiesGen.GetEnumValues <Meaning>();

        lastMeaning = meanings[Random.Range(0, meanings.Length - 1)]; //only war and peace intention

        // Get symbols and generate symbols class
        SymbolsEvents.ActivatePanel(PhraseEvents.GetPhrase().symbols);

        // Activate slider
        SliderEvents.SliderActivation(true);

        // Move space ship
        StartCoroutine(spaceShip.MoveToPosition(timeToReachEarth));

        spaceShip.reset();
        spaceShip.earthObject.GetComponent <EarthEnergyHandler>().reset();

        // AUDIO
        if (lastRace == 0)
        {
            EventManager.Invoke(SoundManagerTopics.PlayEffect, AudioClipName.Cervelloni02);
        }
        else if (lastRace == 1)
        {
            EventManager.Invoke(SoundManagerTopics.PlayEffect, AudioClipName.RobotTalking);
        }
        else
        {
            EventManager.Invoke(SoundManagerTopics.PlayEffect, AudioClipName.Reptilian);
        }
    }
예제 #7
0
    private void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.gameObject.CompareTag("Spaceship"))
        {
            Debug.Log(coll.gameObject.name);
            if (this.transform.parent.parent.CompareTag("Spaceship"))
            {
                return;
            }

            Debug.Log("ENTrato");
            this.transform.parent.parent.GetChild(1).GetComponent <EarthEnergyHandler>().isCollided = true;
            //coll.GetComponent<SpaceShip>().explode();
            EarthEnergyHandler earth = FindObjectOfType <EarthEnergyHandler>();

            earth.attack();
            earth.isCollided = true;
            coll.gameObject.transform.GetChild(0).GetComponent <Image>().color = Color.clear;

            UtilitiesGen.CallMethod(2.2f, () =>
            {
                earth            = FindObjectOfType <EarthEnergyHandler>();
                earth.isCollided = false;
                earth.laser.GetComponent <RectTransform>().sizeDelta = new Vector2(earth.laser.GetComponent <RectTransform>().sizeDelta.x, 0);
                coll.gameObject.transform.GetChild(0).GetComponent <Image>().color = Color.white;
            });
        }
        else if (coll.gameObject.CompareTag("Earth"))
        {
            if (this.transform.parent.parent.GetChild(1).tag == "Earth")
            {
                return;
            }

            this.transform.parent.parent.gameObject.GetComponent <SpaceShip>().isCollided = true;
        }
    }
예제 #8
0
    /// <summary> Play one shot an audio clip effect. </summary>
    /// <param name="_clipName"> Name of audio clip to play. </param>
    /// <param name="_volume"> Optional volume of audio clip. </param>
    private void PlayEffect(AudioClipName _clipName, float _volume = 0.0f)
    {
        if (_clipName.Equals(AudioClipName.None) || repo.effect.source.mute)
        {
            return;
        }

        //repo.effect.source.PlayOneShot(GetClipToEnum(_clipName, SoundType.Effect), Mathf.Approximately(0.0f, _volume) ? repo.effect.source.volume : _volume);

        AudioSource targetSource;

        if (repo.effect.source.clip == null)
        {
            targetSource = repo.effect.source;
        }
        else
        {
            targetSource = repo.effect.source.gameObject.AddComponent <AudioSource>();
        }

        float defaultPitch = targetSource.pitch;

        targetSource.pitch  = Random.Range(.925f, 1.075f);
        targetSource.volume = Mathf.Approximately(0.0f, _volume) ? repo.effect.source.volume : _volume;
        targetSource.clip   = GetClipToEnum(_clipName, SoundType.Effect);
        targetSource.Play();

        if (targetSource != repo.effect.source)
        {
            UtilitiesGen.CallMethod(targetSource.clip.length + 0.5f, () => { Destroy(targetSource); });
        }
        else
        {
            targetSource.pitch = defaultPitch;
        }
    }
예제 #9
0
    public void handleAnswer(Meaning nostro)
    {
        Debug.Log(nostro);

        if (nostro.Equals(Meaning.PEACE))
        {
            if (lastMeaning.Equals(Meaning.PEACE))
            {
                Debug.Log("RIGHT");
                spaceShip.DisableCircleCollider2D();
                spaceShip.StopCoroutineCustom();
                symbols.spawnParticles(Meaning.PEACE);
                spaceShip.Jump();
                pointMgr.spaceShipRight(spaceShip.remainingTimePerc);
                StartCoroutine(delayedGamePhase(2.5f));
            }
            else
            {
                Debug.Log("WRONG");
                spaceShip.DisableCircleCollider2D();
                spaceShip.StopCoroutineCustom();
                pointMgr.spaceShipWrong();
                spaceShip.attack();
                StartCoroutine(delayedGamePhase(3.2f));
                symbols.spawnParticles(Meaning.WAR);
                UtilitiesGen.CallMethod(1.8f, () => { spaceShip.Jump(); });
            }
        }
        else if (nostro.Equals(Meaning.WAR))
        {
            if (lastMeaning.Equals(Meaning.WAR))
            {
                Debug.Log("RIGHT");
                spaceShip.StopCoroutineCustom();
                pointMgr.spaceShipRight(spaceShip.remainingTimePerc);
                symbols.spawnParticles(Meaning.WAR);
                spaceShip.earthObject.GetComponent <EarthEnergyHandler>().attack();
                StartCoroutine(delayedGamePhase(2f));
            }
            else
            {
                Debug.Log("WRONG");
                spaceShip.StopCoroutineCustom();

                cuori.Play();
                //TODO explosion effect and cuoricino spezzato
                pointMgr.DecreasePoint();
                pointMgr.spaceShipWrong();
                spaceShip.earthObject.GetComponent <EarthEnergyHandler>().attack();

                StartCoroutine(delayedGamePhase(2f));
            }
        }
        else if (nostro.Equals(Meaning.NEUTRAL))
        {
            if (lastMeaning.Equals(Meaning.NEUTRAL))
            {
                spaceShip.StopCoroutineCustom();
                Debug.Log("RIGHT");
                pointMgr.spaceShipRight(spaceShip.remainingTimePerc);
                symbols.spawnParticles(Meaning.NEUTRAL);
                StartCoroutine(delayedGamePhase(2f));
            }
            else
            {
                if (lastMeaning.Equals(Meaning.WAR) || lastMeaning.Equals(Meaning.PEACE))
                {
                    Debug.Log("NEW PHRASE");
                    SymbolsEvents.ActivatePanel(PhraseEvents.GetPhrase(true).symbols);
                    symbols.spawnParticles(Meaning.NEUTRAL);
                }
            }
        }
    }