Exemple #1
0
    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;
            }
        });
    }
Exemple #2
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();
            };
        }
    }
Exemple #3
0
    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++;
        });
    }
Exemple #4
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;
        }
    }
Exemple #5
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;
        }
    }
Exemple #6
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);
                }
            }
        }
    }