Exemple #1
0
    void KnifeStuff()
    {
        bool swap = Input.GetKeyDown(KeyCode.Z);

        if (!swap)
        {
            return;
        }
        if (touchedKnife != null && myKnife == null)
        {
            KnifeScript kniS = touchedKnife.GetComponent <KnifeScript>();
            if (!kniS.onGround)
            {
                return;
            }
            kniS.onGround = false;
            Destroy(touchedKnife.GetComponent <Collider>());
            myKnife      = touchedKnife;
            touchedKnife = null;

            SetKnifePosition();
        }
        else if (touchedCube != null)
        {
            CubeMovement mov = touchedCube.GetComponent <CubeMovement>();
            if (myKnife != null || mov.HasKnife())
            {
                myKnife = mov.SwapKnives(myKnife);
                if (myKnife != null)
                {
                    SetKnifePosition();
                }
            }
        }
    }
Exemple #2
0
 void Awake()
 {
     Instance = this;
 }
 private void Awake()
 {
     instance      = this;
     rb            = GetComponent <Rigidbody2D>();
     knifeCollider = GetComponent <BoxCollider2D>();
 }
Exemple #4
0
 protected override void Awake()
 {
     knife = GetComponentInChildren <KnifeScript>();
     anim  = GetComponent <GoblinAnimation>();
 }