Пример #1
0
    public void PlayerJoined(NinjaController ninja)
    {
        blockers[ninja.PlayerNumber].color = new Color(1, 1, 1, 0);
        spawnPoints.SpawnNinja(ninja, ninja.PlayerNumber, NinjaState.Pregame);

        pregamers.Add(ninja, false);
    }
    // Use this for initialization
    void Start()
    {
        ninja = FindObjectOfType<NinjaController> ();

        if (ninja.transform.localScale.x < 0)
            speed = - speed;
    }
Пример #3
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        NinjaController ninja = animator.GetComponentInParent <NinjaController>();

        float vertical   = Input.GetAxisRaw("Vertical");
        float horizontal = Input.GetAxisRaw("Horizontal");


        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

        if (direction.magnitude >= 0.1f)
        {
            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
            float angle       = Mathf.SmoothDampAngle(ninja.transform.eulerAngles.y, targetAngle, ref TurnSmoothVelocity, TurnSmoothTime);
            ninja.transform.rotation = Quaternion.Euler(0f, angle, 0f);

            Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;

            ninja.RIGID_BODY.MovePosition(ninja.RIGID_BODY.position + moveDir.normalized * Speed * Time.fixedDeltaTime);
        }


        if (!ninja.W && !ninja.A && !ninja.S && !ninja.D)
        {
            animator.SetBool(TransitionParameters.Sprint.ToString(), false);
        }

        if (ninja.IsSlideArea)
        {
            animator.SetBool(TransitionParameters.Slide.ToString(), true);
        }
    }
Пример #4
0
    public void PlayerReady(NinjaController ninja)
    {
        pregamers[ninja] = true;
        ninja.State      = NinjaState.Ready;
        GameUiManager.Instance.SetNinjaAsReady(ninja.PlayerNumber);
        if (pregamers.Count <= 1)
        {
            return;
        }

        var ready = true;

        foreach (var item in pregamers)
        {
            if (item.Value)
            {
                continue;
            }
            ready = false;
            break;
        }

        if (ready && !startedGame)
        {
            GameUiManager.Instance.StartGameCountDown();
            startedGame = true;
        }
    }
Пример #5
0
    private void PlayConfetti(NinjaController winner)
    {
        var settings = confettiParticleSystem.main;

        settings.startColor = winner.NinjaColor;
        confettiParticleSystem.Play();
    }
Пример #6
0
    protected override void NinjaKilled(NinjaController killedNinja)
    {
        Vector2 position = killedNinja.transform.position;

        OnKilledNinja(killedNinja);
        killedNinja.Killed();
        GameManager.Instance.NinjaKilled(killedNinja, position, Thrower);
    }
Пример #7
0
    protected virtual void NinjaKilled(NinjaController killedNinja)
    {
        OnKilledNinja(killedNinja);
        Vector2 position = killedNinja.transform.position;

        killedNinja.Killed();
        GameManager.Instance.NinjaKilled(killedNinja, position);
    }
Пример #8
0
    void Start()
    {
        Debug.Assert(platformPrefab != null);
        Debug.Assert(spawnCount > 0);
        ninja = FindObjectOfType <NinjaController>();

        BoxCollider2D platformCollider = platformPrefab.GetComponent <BoxCollider2D>();

        halfPlatformHeight = platformCollider.size.y / 2;
        xPadding           = (xSpread + 1) * platformCollider.size.x;

        float platformHalfWidth = platformCollider.size.x / 2;

        //just set this game object's position = the main camera's position to avoid local positioning confusion
        transform.position = new Vector2(mainCam.transform.position.x, mainCam.transform.position.y);

        //this is in world coordinates
        float topCamEdge = (mainCam.transform.position.y - mainCam.orthographicSize) + (mainCam.orthographicSize * 2 * ySpread);
        float botCamEdge = (mainCam.transform.position.y - mainCam.orthographicSize) + halfPlatformHeight;

        //the top edge of the camera's y location is relative to this game object's y position
        localTopCamEdge = topCamEdge - transform.position.y;
        localBotCamEdge = botCamEdge - transform.position.y;


        //always assign the first platform to be right below the player at all times

        float randomHeight = Random.Range(localBotCamEdge, localTopCamEdge);

        GameObject platform = Instantiate <GameObject>(platformPrefab, transform, false);

        platform.transform.localPosition = new Vector3(platformHalfWidth, ninja.transform.position.x - this.transform.position.x - platform.GetComponent <BoxCollider2D>().size.x / 2, ninja.transform.position.y - this.transform.position.y - ninja.GetComponent <Collider2D>().bounds.size.y / 2);
        platforms.Add(platform);

        //generate all other platform heights based on the previous platform's height and the player's jump height
        for (int i = 1; i < spawnCount; ++i)
        {
            GameObject prevPlatform = platforms[i - 1];
            float      minHeightMod = prevPlatform.transform.localPosition.y - ninja.jumpHeight;
            float      maxHeightMod = prevPlatform.transform.localPosition.y + ninja.jumpHeight;
            if (minHeightMod < localBotCamEdge)
            {
                minHeightMod = localBotCamEdge;
            }
            if (maxHeightMod > localTopCamEdge)
            {
                maxHeightMod = localTopCamEdge;
            }

            randomHeight = Random.Range(minHeightMod, maxHeightMod);

            GameObject platformClone = Instantiate <GameObject>(platformPrefab, transform, false);
            platformClone.transform.localPosition = new Vector3(i * xPadding + platformHalfWidth, randomHeight, 0.0f);
            platforms.Add(platformClone);
        }

        Debug.Log(mainCam.pixelRect.ToString());
    }
Пример #9
0
    void Awake()
    {
        GameObject parentObject = transform.parent.gameObject;
        parentScript = parentObject.GetComponent<NinjaController> ();
        anim = parentObject.GetComponent<Animator> ();

        otherNinja = null;
        otherNinjaScript = null;
    }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        Enemy_Attack = false;
        Enemy2_Die   = false;
        isWait       = false;

        pointOnce = false;
        NinjaControllerScriptE2S = GameObject.Find("Ninja").GetComponent <NinjaController> ();
    }
Пример #11
0
    void OnTriggerStay2D(Collider2D col)
    {
        if (otherNinja == null && col.gameObject.tag == "ninjaFeet"){
            Debug.Log ("There's a Ninja on my head...");

            otherNinja = col.transform.parent.gameObject;
            otherNinjaScript = otherNinja.GetComponent<NinjaController> ();
            parentScript.setNinjaOnTop (otherNinjaScript);
        }
    }
Пример #12
0
    void OnTriggerEnter2D(Collider2D other)
    {
        NinjaController ninja = other.gameObject.GetComponent <NinjaController>();

        if (ninja == true)
        {
            Score.AddScore(value);
            Destroy(this.gameObject);
        }
    }
Пример #13
0
    // Use this for initialization
    void Start()
    {
        Enemy_Attack = false;
        Enemy_Die    = false;
        GameObject.Find("enemy_Sword").SetActive(true);
        pointOnce = false;

        isSndWait = false;

        NinjaControllerScriptES = GameObject.Find("Ninja").GetComponent <NinjaController> ();
    }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        n = GameObject.FindGameObjectWithTag ("ninja");
        controller = n.GetComponent<NinjaController> ();

        if (!controller.facingRight) {
            shurikenSpeed = -shurikenSpeed;
        }

        GetComponent<Rigidbody2D> ().AddForce (new Vector2 (shurikenSpeed, 0));
    }
Пример #15
0
    // Use this for initialization
    void Start()
    {
        _coins      = GameObject.FindGameObjectsWithTag("Coin");
        _totalCoins = _coins.Length;

        _ninjaController = ninja.GetComponent <NinjaController>();
        _collectedCoins  = _ninjaController.score;

        _scoreText      = score.GetComponent <Text>();
        _scoreText.text = string.Format("{0:00} / {1:00}", _collectedCoins, _totalCoins);
    }
Пример #16
0
    public void NinjaKilled(NinjaController killedNinja, Vector3 deathPosition, NinjaController killerNinja = null)
    {
        if (GameState == State.Playing)
        {
            currentScoresManager.NinjaKilled(killedNinja, killerNinja);
        }

        var accessoryDrop = Instantiate(accessoryDropPrefab, deathPosition, Quaternion.identity);

        accessoryDrop.GetComponent <AccessoryDrop>().SetUp(killedNinja.HatSprite.sprite);

        CreateBackgroundBloodSplatter(deathPosition, killedNinja.NinjaColor);
    }
Пример #17
0
    void Awake()
    {
        NinjaAniSprite = GetComponent<SpriteRenderer> ();

        if (NinjaAniSprite.enabled)
            NinjaAniSprite.enabled = false;

        anim = GetComponent<Animator> ();

        // get parent information
        GameObject parentObject = transform.parent.gameObject;
        parentScript = parentObject.GetComponent<NinjaController> ();
    }
Пример #18
0
    void Awake()
    {
        anim = GetComponent<Animator> ();
        NinjaSprite = GetComponent<SpriteRenderer> ();

        // get child information
        Transform childTransform = transform.FindChild ("NinjaAni");
        NinjaAniGO = childTransform.gameObject;
        NinjaAniScript = NinjaAniGO.GetComponent<NinjaAnimation> ();

        NinjaOnTop = null;
        facingRight = true;
    }
Пример #19
0
 public void AddPlayer(NinjaController ninja)
 {
     participatingNinjas.Add(ninja);
     ninja.Description      = ninjaPicker.GetDescription();
     ninja.HatSprite.sprite = ninjaPicker.GetNextHat().Sprite;
     ninja.SetUpBody(ninjaBodies[participatingNinjas.Count - 1]);
     GameUiManager.Instance.AddPlayer(ninja);
     pregameManger.PlayerJoined(ninja);
     if (participatingNinjas.Count == 1)
     {
         PickLevel();
     }
 }
Пример #20
0
    void OnTriggerExit2D(Collider2D col)
    {
        if (otherNinja && col.gameObject.tag == "ninjaFeet") {
            Debug.Log ("No Ninja on my head...");

            // set stuff to null because Ninja is no longer on top
            otherNinja = null;
            otherNinjaScript = null;
            parentScript.setNinjaOnTop (null);

            // set jump delay, penalty for allowing a ninja to jump off of you
            // this would be a good time to switch back to idle animation maybe?
            // if we were to add an animation for holding a ninja on top
            parentScript.setJumpDelay (.5f);
        }
    }
Пример #21
0
    private void Start()
    {
        distanceJoint = GetComponent <DistanceJoint2D>();
        nodes.Add(distanceJoint);
        NinjaController ninja = GetComponentInParent <NinjaController>();

        distanceJoint.connectedBody = ninja.Rigidbody;

        for (int i = 0; i < nodeCount; i++)
        {
            var node = Instantiate(nodePrefab, transform.position, Quaternion.identity);
            node.transform.SetParent(transform);
            var joint = node.GetComponent <DistanceJoint2D>();
            joint.connectedBody = nodes[i].GetComponent <Rigidbody2D>();
            nodes.Add(joint);
        }
    }
Пример #22
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         NinjaController controller = col.gameObject.GetComponent <NinjaController>();
         if (col.collider is CircleCollider2D &&
             col.contacts[0].otherCollider is CircleCollider2D &&
             !isInState("Die"))
         {
             killedBy = KILLED_BY_JUMPED_ON;
             Die();
         }
         if ((controller.CurrentState & NinjaController.FLAG_STATE_SLIDE) > 0)
         {
             killedBy = KILLED_BY_SLIDE;
             Die();
         }
     }
 }
Пример #23
0
 public void setNinjaOnTop(NinjaController otherNinjaScript)
 {
     NinjaOnTop = otherNinjaScript;
 }