Ejemplo n.º 1
0
    void Update()
    {
        if (onAir == true)
        {
            GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <PlayerManager>().DisablePlayerShooting();

            Vector3 pos;
            if (this.GetFloorPosition(out pos) == true)
            {
                this.transform.position = pos;
            }

            if (Input.GetMouseButtonDown(0) == true)
            {
                this.onAir = false;

                //Send Message To Server
                gameObject.SetActive(false);
                Destroy(gameObject);
                GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <PlayerManager>().EnablePlayerShooting();

                MsgCSTrapIn          msg    = new MsgCSTrapIn(this.transform.position, this.trapID);
                NetworkMsgSendCenter center = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
                center.SendMessage(msg);
            }
            else if (Input.GetMouseButtonDown(1) == true)
            {
                gameObject.SetActive(false);
                Destroy(gameObject);

                GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <PlayerManager>().EnablePlayerShooting();
            }
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     enemymanager = GetComponent<EnemyManager>();
     playermanager = GetComponent<PlayerManager>();
     trapmanager = GetComponent<TrapManager>();
     msgcenter = GetComponent<NetworkMsgSendCenter>();
 }
Ejemplo n.º 3
0
    void ShootArrow()
    {
        timerBullets = 0f;
        effecttime   = 0f;

        gunAudio.Play();

        gunLight.color   = new Color(0.9f, 0.9f, 0.0f);
        gunLight.enabled = true;

        gunParticles.Stop();
        gunParticles.Play();

        gunLine.material = this.materials[0];

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);


        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damagePerShot, shootHit.point);

                MsgCSAttack msg = new MsgCSAttack(this.GetComponentInParent <EntityAttributes>().EntityID, shootHit.collider.GetComponent <EntityAttributes>().EntityID, shootRay.origin, shootHit.point, MsgCSAttack.WEAPON_ATTACK);

                NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
                msgcenter.SendMessage(msg);
            }
            else
            {
                MsgCSAttack msg = new MsgCSAttack(this.GetComponentInParent <EntityAttributes>().EntityID, -1, new Vector3(0, 0, 0), new Vector3(0, 0, 0), MsgCSAttack.WEAPON_ATTACK);

                NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
                msgcenter.SendMessage(msg);
            }

            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);

            MsgCSAttack msg = new MsgCSAttack(this.GetComponentInParent <EntityAttributes>().EntityID, -1, new Vector3(0, 0, 0), new Vector3(0, 0, 0), MsgCSAttack.WEAPON_ATTACK);

            NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
            msgcenter.SendMessage(msg);
        }
    }
Ejemplo n.º 4
0
    void Awake()
    {
        floorMask = LayerMask.GetMask("floor");

        anim = GetComponent <Animator> ();

        playerRigidbody = GetComponent <Rigidbody> ();

        msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();

        moveSum = new Vector3(0, 0, 0);
    }
Ejemplo n.º 5
0
    void Attack()
    {
        timer = 0f;

        if (playerHealth.currentHealth > 0)
        {
            playerHealth.TakeDamage(attackDamage);

            GameObject           player    = GameObject.FindGameObjectWithTag("Player");
            MsgCSEnemyAttack     msg       = new MsgCSEnemyAttack(this.GetComponentInParent <EntityAttributes>().EntityID, player.GetComponent <EntityAttributes>().EntityID);
            NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
            msgcenter.SendMessage(msg);
        }
    }
Ejemplo n.º 6
0
    void OnTriggerEnter(Collider other)
    {
        EnemyManager em = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <EnemyManager>();

        if (em.IsEnemyGameObject(other.gameObject) == true)
        {
            other.gameObject.GetComponent <EnemyHealth>().Hurt();
            int id1 = gameObject.GetComponent <EntityAttributes>().EntityID;
            int id2 = other.gameObject.GetComponent <EntityAttributes>().EntityID;

            MsgCSTrapAttack      msg    = new MsgCSTrapAttack(id1, id2);
            NetworkMsgSendCenter center = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
            center.SendMessage(msg);
        }
    }
Ejemplo n.º 7
0
    void Attack()
    {
        if (player == null)
        {
            return;
        }

        if (timer < timeBwteenAttacks || playerHealth.currentHealth < 0 || enemyHealth.currentHealth < 0)
        {
            return;
        }

        Vector3 posPlayer  = player.transform.position;
        Vector3 posCurrent = this.firepoint.position;

        posPlayer.y = posCurrent.y;

        Vector3 vec = posPlayer - posCurrent;

        if (vec.magnitude < attackRange)
        {
            shootRay.origin = this.firepoint.position;
            vec.Normalize();

            shootRay.direction = vec;

            if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
            {
                PlayerHealth playerHealth = shootHit.collider.GetComponent <PlayerHealth>();
                if (playerHealth != null)
                {
                    playerHealth.TakeDamage(attackDamage);

                    timer = 0;

                    gunLine.enabled = true;
                    gunLine.SetPosition(0, shootRay.origin);
                    gunLine.SetPosition(1, posPlayer);

                    GameObject           player    = GameObject.FindGameObjectWithTag("Player");
                    MsgCSEnemyAttack     msg       = new MsgCSEnemyAttack(this.GetComponentInParent <EntityAttributes>().EntityID, player.GetComponent <EntityAttributes>().EntityID);
                    NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
                    msgcenter.SendMessage(msg);
                }
            }
        }
    }
Ejemplo n.º 8
0
    void ShootMagic()
    {
        timerMagic = 0f;
        effecttime = 0f;

        gunAudio.Play();
        gunLight.enabled = true;
        gunLight.color   = new Color(0.1f, 0.3f, 1.0f);

        gunParticles.Stop();
        gunParticles.Play();

        gunLine.material = this.materials[1];

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            float      radius    = 3.0f;
            Collider[] colliders = Physics.OverlapSphere(shootHit.point, radius);

            foreach (Collider cld in colliders)
            {
                EnemyHealth enemyHealth = cld.GetComponent <EnemyHealth>();
                if (enemyHealth != null)
                {
                    enemyHealth.TakeMagicDamage(this.magicPerShot);
                }
            }

            if (colliders.Length > 0)
            {
                MsgCSAttack msg = new MsgCSAttack(this.GetComponentInParent <EntityAttributes>().EntityID, shootHit.collider.GetComponent <EntityAttributes>().EntityID, shootRay.origin, shootHit.point, MsgCSAttack.MAGIC_ATTACK);

                NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
                msgcenter.SendMessage(msg);
            }
            else
            {
                MsgCSAttack msg = new MsgCSAttack(this.GetComponentInParent <EntityAttributes>().EntityID, -1, new Vector3(0, 0, 0), new Vector3(0, 0, 0), MsgCSAttack.MAGIC_ATTACK);

                NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
                msgcenter.SendMessage(msg);
            }

            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);

            MsgCSAttack msg = new MsgCSAttack(this.GetComponentInParent <EntityAttributes>().EntityID, -1, new Vector3(0, 0, 0), new Vector3(0, 0, 0), MsgCSAttack.MAGIC_ATTACK);

            NetworkMsgSendCenter msgcenter = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkMsgSendCenter>();
            msgcenter.SendMessage(msg);
        }
    }