예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1") && !SaveState.Instance.playerDead && !SaveState.Instance.activeMenu)
        {
            if (launched && orbEnabled)       // When it's launched, we will teleport to it on left click
            {
                //audio bit
                audioSource.clip = orbteleport;
                audioSource.Play();

                //teleport bit
                transform.position = orb.position;
                OrbToPlayer();
                fade.StartFade(new Color(1.0f, 0.92f, 0.016f, 0.25f), fadeTime / 2);
                StartCoroutine(FadeOut(fadeTime / 2));
            }
            else if (!launched && orbHasClearSpace && canFire)                                                                    // If not launched and other conditions are satisfied, we shoot the orb
            {
                orb.transform.position = player.transform.position + player.transform.TransformDirection(Vector3.forward * 1.5f); // remove this line to not have ball move to centre of screen when shooting
                orb.transform.parent   = null;

                Vector3 target        = player.transform.forward * speed * maxDistance;
                Vector3 forwardVector = (target - orb.transform.localPosition).normalized;
                orb.AddForce(forwardVector * speed);
                lastPos  = orb.transform.position;
                launched = true;
                canFire  = false;
                orbScript.OnLaunched();
                orbInd.Activate(orbInd.gameObject);
            }
            else
            {
                //Play an error sound that player can't shoot
                audioSource.clip = orbfailed;
                audioSource.Play();
            }
        }
        // Calculate distance travelled
        if (launched)
        {
            distanceTravelled += Vector3.Distance(orb.transform.position, lastPos);
            lastPos            = orb.transform.position;
        }
        // Force orb to attach to player
        if (!launched)
        {
            orb.transform.localPosition = new Vector3(player.transform.localPosition.x + 0.4f, player.transform.localPosition.y - 0.85f, player.transform.localPosition.z + 0.6f);
        }
        // When orb reaches max distance, return it to the player.
        if (distanceTravelled >= maxDistance)
        {
            OrbToPlayer();
        }
        // Change colour of orb as it nears the end of its range (2/3 of the way)
        if (distanceTravelled >= maxDistance / 2)
        {
            orbP.startColor = Color.Lerp(Color.blue, Color.red, Time.time / 2);
        }
    }
예제 #2
0
        public override void Start()
        {
            var lastMatchSession = Game.GameSession.MatchSessions.Last();

            m_newMatchInfo                   = new MatchStartInfo();
            m_newMatchInfo.Arena.Name        = lastMatchSession.MatchInfo.Arena.Name;
            m_newMatchInfo.Arena.ColorScheme = lastMatchSession.MatchInfo.Arena.ColorScheme;
            m_newMatchInfo.Players           = new PlayerInfo[4];
            m_newMatchInfo.Players[0]        = lastMatchSession.MatchInfo.Players[0];
            m_newMatchInfo.Players[1]        = lastMatchSession.MatchInfo.Players[1];
            m_newMatchInfo.Players[2]        = lastMatchSession.MatchInfo.Players[2];
            m_newMatchInfo.Players[3]        = lastMatchSession.MatchInfo.Players[3];
            m_newMatchInfo.Teams             = new TeamInfo[2];
            m_newMatchInfo.Teams[0]          = lastMatchSession.MatchInfo.Teams[0];
            m_newMatchInfo.Teams[1]          = lastMatchSession.MatchInfo.Teams[1];

            m_screenFade = new ScreenFade();
            Menu.Owner.Attach(m_screenFade);

            m_screenFade.Opacity = 0.7f;
            m_screenFade.StartFade(ScreenFade.FadeType.FadeIn, 0, false);

            m_matchRestartTimer         = new Timer(Engine.GameTime.Source, 200);
            m_matchRestartTimerEvent    = new TimerEvent(m_matchRestartTimer_OnTime);
            m_matchRestartTimer.OnTime += m_matchRestartTimerEvent;

            //Game.GameMusic.Tracks["MatchStream"].Pause();
        }
예제 #3
0
    public void ShowScreen()
    {
        SaveState.Instance.playerDead = true;
        GameObject.Find("Player").GetComponent <Crosshair>().create = false;
        GameObject.Find("Player").GetComponent <UnityStandardAssets.Characters.FirstPerson.RigidbodyFirstPersonController>().enabled = false;
        fade.StartFade(new Color(1.0f, 0, 0, 0.3f), fadeTime / 2);
        StartCoroutine(FadeOut(fadeTime / 2));
        // Grab any pathing platforms in the level and reset them.
        GameObject[] plaftorms = GameObject.FindGameObjectsWithTag("PathPlatform");
        foreach (GameObject p in plaftorms)
        {
            p.GetComponent <PathingPlatform>().Reset();
        }

        foreach (C2DestructPlatform p in Resources.FindObjectsOfTypeAll <C2DestructPlatform>())
        {
            p.gameObject.GetComponent <C2DestructPlatform>().Reset();
        }

        if (GameObject.Find("OrbContainer"))
        {
            GameObject.Find("OrbContainer").GetComponent <OrbContainer>().ReleaseOrb();
        }
    }
예제 #4
0
        public override void Start()
        {
            m_gamepadCmp = new SpriteComponent(Sprite.CreateFromTexture("Graphics/Menu/GpControls.png"), "MenuBackground");
            Menu.Owner.Attach(m_gamepadCmp);

            m_keyboardCmp = new SpriteComponent(Sprite.CreateFromTexture("Graphics/Menu/KbControls.png"), "MenuBackground");
            Menu.Owner.Attach(m_keyboardCmp);

            m_keyboardCmp.Visible = false;

            m_screenFade = new ScreenFade();
            Menu.Owner.Attach(m_screenFade);

            m_screenFade.Opacity = 0.7f;
            m_screenFade.StartFade(ScreenFade.FadeType.FadeIn, 0, false);
        }
예제 #5
0
        public override void Update()
        {
            CheckForNewPlayers();

            m_timerMSPrevious       = m_timerMS;
            m_elapsedTimeMSPrevious = m_elapsedTime;

            if (Game.AIGameData.IsIdleAIRunning == false || m_matchState != MatchState.FirstPeriod)
            {
                m_timerMS     -= Engine.GameTime.ElapsedMS;
                m_elapsedTime += Engine.GameTime.ElapsedMS;
            }

            UpdateMatchSoundEvents();

            if (m_matchState == MatchState.Init)
            {
                if (m_elapsedTime > 0)
                {
                    m_elapsedTime = 0;
                    ChangeState(MatchState.Begin);
                }
            }

            if (m_matchState == MatchState.Begin)
            {
                if (m_elapsedTime >= m_matchBeginTimer)
                {
                    m_elapsedTime = 0;
                    ChangeState(MatchState.FirstPeriod);
                    Game.Stats.MatchStart();
                }
            }

            if (m_matchState == MatchState.FirstPeriod)
            {
                if (m_elapsedTime >= m_halfTimeDuration)
                {
                    m_elapsedTime = 0;
                    ChangeState(MatchState.HalfTime);
                }
            }
            else if (m_matchState == MatchState.HalfTime)
            {
                Ball ball = Game.GameManager.Ball;

                if (m_matchStateStep == 0 && m_elapsedTime >= m_halfTimePauseDuration[0])
                {
                    ball.BodyCmp.Body.LinearDamping += 0.005f * Engine.GameTime.ElapsedMS;

                    if (ball.Player != null || !ball.BodyCmp.Body.Awake || ball.BodyCmp.Body.LinearVelocity.LengthSquared() < 0.01f)
                    {
                        m_elapsedTime    = 0;
                        m_matchStateStep = 1;

                        ball.BodyCmp.Body.LinearDamping = ball.Parameters.Physic.LinearDamping;

                        ScreenFade screenFade = new ScreenFade();
                        Owner.Attach(screenFade);
                        screenFade.StartFade(ScreenFade.FadeType.FadeOut, 500, false);
                    }
                }
                else if (m_matchStateStep == 1 && m_elapsedTime >= m_halfTimePauseDuration[1])
                {
                    m_elapsedTime    = 0;
                    m_matchStateStep = 4;;

                    Engine.World.EventManager.ThrowEvent((int)EventId.HalfTimeTransition);

                    if (Game.GameManager.Tutorial.Enabled)
                    {
                        m_matchStateStep         = 2;
                        m_tutorialSprite.Visible = true;
                    }
                    else
                    {
                        m_matchStateStep = 4;
                        ScreenFade screenFade = Owner.FindComponent <ScreenFade>();
                        screenFade.StartFade(ScreenFade.FadeType.FadeIn, 500, true);
                    }
                }

                else if (m_matchStateStep == 2 && m_elapsedTime >= m_tutorialDisplayDuration)
                {
                    m_elapsedTime    = 0;
                    m_matchStateStep = 4;

                    m_tutorialSprite.Visible = false;
                    ScreenFade screenFade = Owner.FindComponent <ScreenFade>();
                    screenFade.StartFade(ScreenFade.FadeType.FadeIn, 1000, true);
                }

                else if (m_matchStateStep == 4 && m_elapsedTime >= m_halfTimePauseDuration[2])
                {
                    ChangeState(MatchState.SecondPeriodBegin);
                }
            }
            else if (m_matchState == MatchState.SecondPeriodBegin)
            {
                if (m_elapsedTime >= m_matchBeginTimer)
                {
                    m_elapsedTime = 0;
                    ChangeState(MatchState.SecondPeriod);
                }
            }
            else if (m_matchState == MatchState.SecondPeriod)
            {
                if (m_elapsedTime >= m_halfTimeDuration)
                {
                    m_elapsedTime = 0;
                    ChangeState(MatchState.End);
                }
            }
            else if (m_matchState == MatchState.End)
            {
                Ball ball = Game.GameManager.Ball;

                if (m_matchStateStep == 0 && m_elapsedTime >= m_endGamePauseDuration[0])
                {
                    ball.BodyCmp.Body.LinearDamping += 0.005f * Engine.GameTime.ElapsedMS;

                    if (ball.Player != null || !ball.BodyCmp.Body.Awake || ball.BodyCmp.Body.LinearVelocity.LengthSquared() < 0.01f)
                    {
                        m_elapsedTime = 0;
                        m_matchStateStep++;
                        ball.BodyCmp.Body.LinearDamping = ball.Parameters.Physic.LinearDamping;

                        ScreenFade screenFade = new ScreenFade();
                        Owner.Attach(screenFade);
                        screenFade.StartFade(ScreenFade.FadeType.FadeOut, 500, false);
                    }
                }
                else if (m_matchStateStep == 1 && m_elapsedTime >= m_endGamePauseDuration[1])
                {
                    m_elapsedTime = 0;
                    m_matchStateStep++;
                    Engine.World.EventManager.ThrowEvent((int)EventId.Victory);

                    ScreenFade screenFade = Owner.FindComponent <ScreenFade>();
                    screenFade.StartFade(ScreenFade.FadeType.FadeIn, 500, true);
                }
                else if (m_matchStateStep == 2 && m_elapsedTime >= m_endGamePauseDuration[2])
                {
                    m_elapsedTime = 0;
                    m_matchStateStep++;
                    Engine.World.EventManager.ThrowEvent((int)EventId.MatchFinalize);

                    Game.Stats.MatchEnd();
                }
            }
        }