Example #1
0
    public override void launch()
    {
        this.transform.localRotation = Quaternion.Euler(0, 0, 35);
        this.transform.localScale    = new Vector2(.25f, .25f);

        BoxCollider2D bc = GetComponent <BoxCollider2D> ();

        bc.offset = new Vector2(-0.45f, -0.625f);
        bc.size   = Vector2.one * 0.25f;

        GameObject player_trail = AddTrailToObject(Thrower.transform, this.transform.localPosition);

        playerrope = player_trail.GetComponent <ParticleSystem> ();
        Thrower.GetComponent <PlayerController> ().trailingRope = playerrope;
        emissionDistance = 1f / playerrope.emission.rate.constant;

        GameObject throwable_trail = AddTrailToObject(this.transform, Vector3.zero);

        throwablerope = throwable_trail.GetComponent <ParticleSystem> ();

        if (Letter == "G")
        {
            //change rope color
            Material m = Resources.Load <Material>("Materials/Graphic/GrappleRope");
            playerrope.GetComponent <ParticleSystemRenderer> ().sharedMaterial   = m;
            throwablerope.GetComponent <ParticleSystemRenderer>().sharedMaterial = m;
        }

        base.launch();
    }
Example #2
0
 void StartThrow()
 {
     ActiveRock = Instantiate(RockPrefab);
     rocks.Add(ActiveRock);
     ActiveRock.GetComponent <Rock>().Team    = GetCurrentTeam();
     ActiveRock.GetComponent <Rock>().Minimap = Minimap;
     ActiveRock.GetComponent <Rock>().InstantiateIndicator();
     Thrower.GetComponent <SpriteRenderer>().sprite = GetCurrentTeam().AimSprite;
     Sweeper.GetComponent <SpriteRenderer>().sprite = GetCurrentTeam().SweepSprite;
     Sweeper.GetComponent <Sweeper>().ResetOffsets();
     trajectory          = Instantiate(TrajectoryPrefab);
     trajectoryIndicator = Instantiate(TrajectoryIndicatorPrefab);
     trajectory.transform.SetParent(ActiveRock.transform);
     trajectoryIndicator.transform.SetParent(ActiveRock.GetComponent <Rock>().Indicator.transform);
     trajectory.transform.localPosition          = new Vector3();
     trajectoryIndicator.transform.localPosition = new Vector3();
     CurrentGameState = GameState.AIMING;
     if (CurrentTurn == Turn.P1 ? GameConfig.P1ShowTutorial : GameConfig.P2ShowTutorial)
     {
         helpStage = HelpScreen.ID.SCORING;
     }
 }
Example #3
0
 void ReleaseRock()
 {
     Thrower.GetComponent <Thrower>().Velocity = ActiveRock.GetComponent <Rigidbody2D>().velocity;
     CurrentGameState = GameState.SWEEPING;
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (Paused)
        {
            return;
        }
        if (Utils.GetKeyDown_Escape())
        {
            PausePanel.gameObject.SetActive(true);
            PausePanel.ShowPauseMenu();
        }
        switch (helpStage)
        {
        case HelpScreen.ID.SCORING:
        case HelpScreen.ID.INTERFACE:
        case HelpScreen.ID.AIMING_AND_THROWING:
            ShowHelp();
            break;

        case HelpScreen.ID.SPIN:
            if (CurrentGameState == GameState.THROWING)
            {
                ShowHelp();
            }
            break;

        case HelpScreen.ID.SWEEPING:
            if (CurrentGameState == GameState.SWEEPING)
            {
                ShowHelp();
            }
            break;

        case HelpScreen.ID.FINAL:
            if (watchingFrameCounter == 1)
            {
                ShowHelp();
            }
            break;
        }
        if (Paused)
        {
            foreach (GameObject rock in rocks)
            {
                rock.GetComponent <Rock>().MuteTemporarily();
            }
            return;
        }
        switch (CurrentGameState)
        {
        case GameState.PRE_GAME:
            StartEnd();
            break;

        case GameState.AIMING:
            float currentRotation = trajectory.transform.rotation.eulerAngles.z;
            float rotateSpeed     = 0.1f;
            float rotateLimit     = 3f;
            if (Utils.GetKey_Up() && !(180 > currentRotation && currentRotation > rotateLimit))
            {
                trajectory.transform.Rotate(0, 0, rotateSpeed);
                trajectoryIndicator.transform.Rotate(0, 0, rotateSpeed);
            }
            if (Utils.GetKey_Down() && !(180 < currentRotation && currentRotation < 360 - rotateLimit))
            {
                trajectory.transform.Rotate(0, 0, -rotateSpeed);
                trajectoryIndicator.transform.Rotate(0, 0, -rotateSpeed);
            }
            trajectoryIndicator.transform.rotation = trajectory.transform.rotation;
            if (Utils.GetKeyDown_Confirm())
            {
                ActiveRock.transform.position += new Vector3(0.45f, 0);                         // ick magic constant
                Thrower.GetComponent <SpriteRenderer>().sprite = GetCurrentTeam().ThrowSprite;
                float rad = Mathf.Deg2Rad * trajectory.transform.rotation.eulerAngles.z;
                Destroy(trajectory);
                Destroy(trajectoryIndicator);
                ActiveRock.GetComponent <Rigidbody2D>().velocity = new Vector3(4.2f * Mathf.Cos(rad), 4.2f * Mathf.Sin(rad));
                CurrentGameState = GameState.THROWING;
            }

            break;

        case GameState.THROWING:
            if (Utils.GetKeyDown_Confirm() || ActiveRock.transform.position.x > Hogline1.transform.position.x)
            {
                ReleaseRock();
            }

            break;

        case GameState.SWEEPING:
            if (ActiveRock.transform.position.x > House.transform.position.x ||
                ActiveRock.GetComponent <Rigidbody2D>().velocity.magnitude < 0.2f ||
                ActiveRock.GetComponent <Rock>().OutOfBounds)
            {
                watchingFrameCounter = 0;
                CurrentGameState     = GameState.WATCHING;
            }

            break;

        case GameState.WATCHING:
            if (watchingFrameCounter > 0)
            {
                if (watchingFrameCounter++ > 90)                         // 1.5 seconds
                {
                    EndThrow();
                }
            }
            else
            {
                watchingFrameCounter = 1;
                foreach (GameObject rock in rocks)
                {
                    Rigidbody2D rb = rock.GetComponent <Rigidbody2D>();
                    if (!rock.GetComponent <Rock>().OutOfBounds &&
                        (rb.velocity.magnitude > 0.01f ||
                         Mathf.Abs(rb.angularVelocity) > 0.01f))
                    {
                        watchingFrameCounter = 0;
                    }
                }
            }

            break;
        }
    }