Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (!movementCheck.CheckMove(this.transform.position))
        {
            GameObject hitObject = movementCheck.HitObject(this.transform.position);

            if (LayerMask.NameToLayer("Enemy") == hitObject.layer || LayerMask.NameToLayer("Player") == hitObject.layer || LayerMask.NameToLayer("Destructable") == hitObject.layer)
            {
                damageBehaviour(hitObject, damage, caster);
                //hitObject.GetComponent<Health>().TakeDamage(damageBehaviour(hitObject,damage);
                gameObject.SetActive(false);
            }
            else if (LayerMask.NameToLayer("ProjectilePlayer") == hitObject.layer)
            {
                ProjectileDispute(hitObject.GetComponent <ProjectileCollision>());
            }
            else if (LayerMask.NameToLayer("ProjectileEnemy") == hitObject.layer)
            {
            }
            else if (LayerMask.NameToLayer("BackGround") == hitObject.layer)
            {
                if (collideWithBack)
                {
                    hitObject.gameObject.GetComponent <WallSound>().Play();
                    backGroundCollisionBehaviour(gameObject, movementCheck);
                }
            }
            else
            {
                gameObject.SetActive(false);
            }
        }
    }
Beispiel #2
0
    void Move()
    {
        Vector3 moveVector = new Vector3(0, 0, 0);

        if (Input.GetKey(KeyCode.A))
        {
            moveVector = moveVector + new Vector3(-1, 0, 0);
            if (anim.gameObject.transform.localScale.x > 0)
            {
                anim.gameObject.transform.localScale = new Vector3(anim.gameObject.transform.localScale.x * -1, anim.gameObject.transform.localScale.y, anim.gameObject.transform.localScale.z);
            }
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveVector = moveVector + new Vector3(1, 0, 0);
            if (anim.gameObject.transform.localScale.x < 0)
            {
                anim.gameObject.transform.localScale = new Vector3(anim.gameObject.transform.localScale.x * -1, anim.gameObject.transform.localScale.y, anim.gameObject.transform.localScale.z);
            }
        }
        if (Input.GetKey(KeyCode.W))
        {
            moveVector = moveVector + new Vector3(0, 1, 0);
        }
        if (Input.GetKey(KeyCode.S))
        {
            moveVector = moveVector + new Vector3(0, -1, 0);
        }

        Vector3 pos = this.transform.position + (moveVector * speed * speedMod * shoot.GetSpeedMod() * Time.deltaTime);

        if (mc.CheckMove(pos))
        {
            if (moveVector == Vector3.zero)
            {
                reflection.SetBool("Walking", false);
            }
            else
            {
                reflection.SetBool("Walking", true);
            }
            direction = moveVector;
            this.transform.position = pos;
        }
    }