Beispiel #1
0
    void Update()
    {
        RaycastHit2D hitInfoRight;
        RaycastHit2D hitInfoLeft;

        hitInfoRight = Physics2D.Raycast(rightCheck.position, Vector2.up, 50f);
        hitInfoLeft  = Physics2D.Raycast(leftCheck.position, Vector2.up, 50f);

        if (hitInfoLeft && hitInfoLeft.transform.tag == "Boss")
        {
            transform.eulerAngles = new Vector3(0, 180, 0);
        }
        else if (hitInfoRight && hitInfoRight.transform.tag == "Boss")
        {
            transform.eulerAngles = new Vector3(0, 0, 0);
        }

        if (jumpBehaviour && jumpBehaviour.spikeFalling)
        {
            InternalDebug.Log("b");
            StartCoroutine(SpawnSpikes());
            spikeFallCounts           += 1;
            jumpBehaviour.spikeFalling = false;
        }
    }
    public static void ToBinary <T>(T _data, string _roomName)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string _path = Path.Combine(path, _roomName);

        using FileStream stream = new FileStream(_path, FileMode.Create);
        formatter.Serialize(stream, _data);
        InternalDebug.Log("Save");
    }
Beispiel #3
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (timeValue <= 0)
     {
         animator.ResetTrigger("Jump");
         animator.SetTrigger("Idle");
         InternalDebug.Log("Set trigger idle");
     }
     else
     {
         timeValue -= Time.deltaTime;
     }
 }
Beispiel #4
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag.Equals("Player"))
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
     else if (collision.tag.Equals("Ground"))
     {
         InternalDebug.Log("c");
         speed = 0;
         Destroy(gameObject, 2);
     }
     else if (collision.tag.Equals("Boss"))
     {
         Destroy(gameObject);
     }
 }
Beispiel #5
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        timeValue = timer;
        playerPos = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
        rb        = animator.GetComponent <Rigidbody2D>();

        if (spikeCanFalling)
        {
            timeValue = 2.1f;
            InternalDebug.Log(timeValue);
            spikeFalling    = true;
            spikeCanFalling = false;
            InternalDebug.Log(spikeCanFalling);
        }
        else
        {
            Vector2 target = new Vector2(playerPos.position.x, animator.gameObject.transform.position.y);
            rb.velocity = -animator.transform.right * speed;
            jumpCounts += 1;
        }
    }
Beispiel #6
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (timeValue <= 0 && jumpBehaviour && jumpBehaviour.jumpCounts < jumpBehaviour.maxJumps)
     {
         animator.ResetTrigger("Idle");
         animator.SetTrigger("Jump");
         InternalDebug.Log("SetTriggerJump");
         InternalDebug.Log("Jump counts: " + jumpBehaviour.jumpCounts);
     }
     else if (timeValue <= 0 && jumpBehaviour.jumpCounts >= jumpBehaviour.maxJumps)
     {
         animator.ResetTrigger("Idle");
         animator.ResetTrigger("Jump");
         animator.SetTrigger("Dash");
         InternalDebug.Log("Set Trigger Dash");
         InternalDebug.Log("Jump counts: " + jumpBehaviour.jumpCounts);
     }
     else
     {
         timeValue -= Time.deltaTime;
     }
 }
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if ((dashCounts >= maxDash) && timeValue <= 0)
     {
         jumpBehaviour.spikeCanFalling = true;
         animator.ResetTrigger("Idle");
         animator.ResetTrigger("Dash");
         animator.SetTrigger("Jump");
         dashCounts = 0;
         InternalDebug.Log("d");
     }
     else if (timeValue <= 0 && dashCounts < maxDash)
     {
         animator.ResetTrigger("Dash");
         animator.ResetTrigger("Jump");
         animator.SetTrigger("Idle");
     }
     else
     {
         timeValue -= Time.deltaTime;
     }
 }