Ejemplo n.º 1
0
        void CheckAttack()
        {
            attackCooldown.CooldownUpdate();

            if (Input.GetMouseButton(0) && !attackCooldown.IsOnCooldown())
            {
                Debug.Log("Launch Attack");
                attackCooldown.StartCooldown();

                //Define Attack
                //Animation
                Collider[] hitEnemies = Physics.OverlapSphere(meleeAttackPoint.position, attackRange, ennemyLayers);
                foreach (Collider enemy in hitEnemies)
                {
                    Debug.Log("We hit " + enemy.name);
                    //The dmg are taken in the server
                    //Send Attack
                    combatData.initiatorId = this.networkIdentity.GetId();
                    combatData.targetId    = enemy.GetComponent <NetworkIdentity>().GetId();
                    combatData.ammount     = attackDmg.ToString();

                    networkIdentity.GetSocket().Emit("takeDamage", new JSONObject(JsonUtility.ToJson(combatData)));
                }
            }
        }
Ejemplo n.º 2
0
        public void runCheck()
        {
            shootingCooldown.CooldownUpdate();

            if (Input.GetMouseButton(0) && !shootingCooldown.IsOnCooldown())
            {
                fireBullet();
            }
        }
Ejemplo n.º 3
0
 public void CheckWeaponAttack()
 {
     cooldownBetweenWeaponAttack.CooldownUpdate();
     if (Input.GetMouseButtonDown(0) & !cooldownBetweenWeaponAttack.IsOnCooldown())
     {
         cooldownBetweenWeaponAttack.StartCooldown();
         this.animator.SetTrigger("WeaponAttack");
         //Attack
     }
     //TODO: first make spell attack work and spell system
 }
Ejemplo n.º 4
0
 private void CheckShooting()
 {
     shootingCooldown.CooldownUpdate();
     if (Input.GetButton("Fire1") && !shootingCooldown.IsOnCooldown())
     {
         StartCoroutine(Aiming());
         shootingCooldown.StartCooldown();
         //Define bullet
         bulletData.activator = NetworkClient.ClientID;
         bulletData.position.VectorToString(bulletSpawnPoint.position);
         bulletData.direction.VectorToString(-bulletSpawnPoint.forward);
         //Send bullet
         networkIdentity.GetSocket().Emit("fireBullet", new JSONObject(JsonUtility.ToJson(bulletData)));
     }
 }
Ejemplo n.º 5
0
        /*private void checkRotation() {
         *  Ray camRay = playerCamera.ScreenPointToRay(Input.mousePosition);
         *  RaycastHit floorHit;
         *
         *  if (Physics.Raycast(camRay, out floorHit, Mathf.Infinity, levelMask)) {
         *      Vector3 playerToMouse = floorHit.point - playerManager.GetCurrentPosition();
         *      playerToMouse.y = 0f;
         *      Quaternion newRotation = Quaternion.identity;
         *      newRotation = Quaternion.LookRotation(playerToMouse);
         *      OnRotation.Invoke(newRotation);
         *  }
         * }*/

        private void checkActions()
        {
            //Action (Attack/Swing)
            //Interaction
            //Dash (Utility?)

            //Update cooldowns
            actionCooldown.CooldownUpdate();
            interactionCooldown.CooldownUpdate();
            dashCooldown.CooldownUpdate();
            jumpCooldown.CooldownUpdate();

            //Handle input

            //Action
            if (Input.GetMouseButton(0) && !actionCooldown.IsOnCooldown())
            {
                actionCooldown.StartCooldown();
                OnAction.Invoke();
            }

            if (Input.GetKeyDown(interaction) && !interactionCooldown.IsOnCooldown())
            {
                interactionCooldown.StartCooldown();
                OnInteractionRequest.Invoke();
            }

            if (Input.GetKeyDown(jump))
            {
                OnJump.Invoke();
            }

            if (Input.GetKeyUp(jump))
            {
                OnStopJump.Invoke();
            }

            if (Input.GetKeyDown(dash))
            {
                OnDash.Invoke();
            }

            if (Input.GetKeyUp(dash))
            {
                OnDashStop.Invoke();
            }
        }
Ejemplo n.º 6
0
        private void checkShooting()
        {
            shootingCooldown.CooldownUpdate();

            if (Input.GetMouseButton(0) && !shootingCooldown.IsOnCooldown())
            {
                shootingCooldown.StartCooldown();

                bulletData.activator   = NetworkClient.ClientID;
                bulletData.position.x  = bulletSpawnPoint.position.x.TwoDecimals();
                bulletData.position.y  = bulletSpawnPoint.position.y.TwoDecimals();
                bulletData.direction.x = bulletSpawnPoint.up.x;
                bulletData.direction.y = bulletSpawnPoint.up.y;

                networkIdentity.GetSocket().Emit("fireBullet", new JSONObject(JsonUtility.ToJson(bulletData)));
            }
        }
Ejemplo n.º 7
0
        private void CheckShooting()
        {
            shootingCooldown.CooldownUpdate();
            if (Input.GetMouseButton(0) && !shootingCooldown.IsOnCooldown())
            {
                shootingCooldown.StartCooldown();

                // define bullet
                projectileData.activator  = NetworkClient.ClientID;
                projectileData.position.x = projectileSpawn.position.x.TwoDecimals();
                projectileData.position.y = projectileSpawn.position.y.TwoDecimals();

                projectileData.direction.x = projectileSpawn.up.x;
                projectileData.direction.y = projectileSpawn.up.y;
                //send bullet
                networkIdentity.GetSocket().Emit("fireProjectile", JsonUtility.ToJson(projectileData));
            }
        }
Ejemplo n.º 8
0
        private void CheckSpellAttack()
        {
            cooldownActualSpell.CooldownUpdate();

            Spell spellSelected = this.spellBook.GetSpellSelected();

            if (spellSelected != null && !cooldownActualSpell.IsOnCooldown())  //Fix the condition with cooldown
            {
                if (this.stats.currentMana >= spellSelected.manaCost)
                {
                    this.stats.UseMana(spellSelected.manaCost);

                    cooldownActualSpell.SetCooldown(spellSelected.castingTime);
                    cooldownActualSpell.StartCooldown();

                    this.animator.SetTrigger("SpellAttack");
                    this.FireSpell(spellSelected);
                }
            }
        }