Exemplo n.º 1
0
 public void ShootInActor(Actor target)
 {
     if (target != null)
     {
         EquipedWeapon.Shoot(target.BodyCenter.position);
     }
 }
Exemplo n.º 2
0
        private EquipedWeapon InitializeWeapon(Weapon weapon)
        {
            Animator animator = GetComponent <Animator>();

            weaponReference = weapon.Equip(transform, rightWeaponHolder, leftWeaponHolder, animator);
            return(weaponReference);
        }
Exemplo n.º 3
0
 public override void Attack(PawnBehaviour target)
 {
     if (EquipedWeapon != null)
     {
         EquipedWeapon.PlayerAttack(this, attackAngle);
     }
 }
Exemplo n.º 4
0
    public void CheckItem()
    {
        if (currentItem != null && Input.GetKeyDown(keyAccion))
        {
            switch (currentItem.typeItem)
            {
            case Item.TypeItem.BrazoDeShoker:
                life          = life + currentItem.lifeRecover;
                equipedWeapon = EquipedWeapon.BrazoDeShoker;
                Destroy(currentItem.gameObject);
                break;

            case Item.TypeItem.Default:
                life          = life + currentItem.lifeRecover;
                equipedWeapon = EquipedWeapon.Default;
                Destroy(currentItem.gameObject);
                break;

            case Item.TypeItem.RifleTracker:
                life          = life + currentItem.lifeRecover;
                equipedWeapon = EquipedWeapon.RifleTracker;
                Destroy(currentItem.gameObject);
                break;

            case Item.TypeItem.SableAssasin:
                life          = life + currentItem.lifeRecover;
                equipedWeapon = EquipedWeapon.SableAssasin;
                Destroy(currentItem.gameObject);
                break;
            }
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(inFloor);

        CheckHealling();
        CheckLife(maxLife);
        if (enableMovement)
        {
            Movement();
            CheckDie();
            CheckStatePlayer();
            CheckWeapon();
            update_life_bar();
            updateAnimator();
            if (currentItem != null)
            {
                CheckItem();
            }
            if (equipedWeapon == EquipedWeapon.RifleTracker)
            {
                if (Input.GetKeyDown(keyAttack))
                {
                    distaceWeapon.ShootWeapon();
                    currentWeapon.CountUse--;
                    distaceWeapon.CountUse--;
                    if (currentWeapon.CountUse <= 0 || distaceWeapon.CountUse <= 0)
                    {
                        equipedWeapon = EquipedWeapon.Default;
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Make this character shoot in some direction.
 /// </summary>
 /// <param name="target">If default - target is mouse position.</param>
 public void Shoot(Vector3 target = default)
 {
     if (!readyToShoot)
     {
         if (EquipedWeapon.Settings.HoldingType != WeaponHoldingType.Sword)
         {
             StartCustomCoroutine(() =>
             {
                 AnimationModule.SetAnimationTrigger("Aim" + EquipedWeapon.Settings.HoldingType.ToString());
                 readyToShootTimer -= 0.03f;
             }, -1, 0.03f, () => { return(readyToShootTimer <= 0); }, () =>
             {
                 readyToShoot   = true;
                 headLookingPos = InputManager.Instance.MouseWorldPosition;
                 EquipedWeapon.Shoot();
                 readyToShootTimer = 0.25f;
             }
                                  );
         }
         else
         {
             EquipedWeapon.Shoot();
             readyToShootTimer = EquipedWeapon.Settings.AttackInterval;
         }
     }
     else
     {
         AnimationModule.SetAnimationTrigger("Aim" + EquipedWeapon.Settings.HoldingType.ToString());
         headLookingPos = InputManager.Instance.MouseWorldPosition;
         EquipedWeapon.Shoot();
     }
 }
Exemplo n.º 7
0
    public void CheckWeapon()
    {
        if (currentWeapon != null)
        {
            if (Input.GetKey(keyAttack) && inFloor)
            {
                switch (equipedWeapon)
                {
                case EquipedWeapon.Default:
                    DefaultWeapon.gameObject.SetActive(true);
                    BrazosDeShokerWeapon.gameObject.SetActive(false);
                    SableAssasinWeapon.gameObject.SetActive(false);
                    RifleTrackerWeapon.gameObject.SetActive(false);
                    distaceWeapon = null;
                    currentWeapon = DefaultWeapon;
                    break;

                case EquipedWeapon.BrazoDeShoker:
                    DefaultWeapon.gameObject.SetActive(false);
                    BrazosDeShokerWeapon.gameObject.SetActive(true);
                    SableAssasinWeapon.gameObject.SetActive(false);
                    RifleTrackerWeapon.gameObject.SetActive(false);
                    distaceWeapon = null;
                    currentWeapon = BrazosDeShokerWeapon;
                    break;

                case EquipedWeapon.SableAssasin:
                    DefaultWeapon.gameObject.SetActive(false);
                    BrazosDeShokerWeapon.gameObject.SetActive(false);
                    SableAssasinWeapon.gameObject.SetActive(true);
                    RifleTrackerWeapon.gameObject.SetActive(false);
                    distaceWeapon = null;
                    currentWeapon = SableAssasinWeapon;
                    break;

                case EquipedWeapon.RifleTracker:
                    DefaultWeapon.gameObject.SetActive(false);
                    BrazosDeShokerWeapon.gameObject.SetActive(false);
                    SableAssasinWeapon.gameObject.SetActive(false);
                    RifleTrackerWeapon.gameObject.SetActive(true);
                    currentWeapon = RifleTrackerWeapon;
                    distaceWeapon = RifleTrackerWeapon;
                    break;
                }
                if (currentWeapon.CountUse <= 0)
                {
                    equipedWeapon = EquipedWeapon.Default;
                }
                if (distaceWeapon != null)
                {
                    if (distaceWeapon.CountUse <= 0)
                    {
                        equipedWeapon = EquipedWeapon.Default;
                    }
                }
            }
        }
    }
Exemplo n.º 8
0
 protected override void Start()
 {
     base.Start();
     inLadder       = false;
     rigidbody      = GetComponent <Rigidbody2D>();
     equipedWeapon  = EquipedWeapon.Default;
     healthBar      = GameObject.FindWithTag("HealthBar").GetComponent <HealthBar>();
     enableMovement = true;
 }
        public void EquipWeapon(GameObject weapon)
        {
            if (EquipedWeapon != null)
            {
                _playerStats.RemoveBonus(EquipedWeapon.GetComponent <IWeapon>().WeaponStats);
                Destroy(rightHand.transform.GetChild(0).gameObject);
            }

            EquipedWeapon = Instantiate(weapon, rightHand.transform.position, rightHand.transform.rotation * weapon.transform.rotation);
            _playerStats.AddStatBonus(EquipedWeapon.GetComponent <IWeapon>().WeaponStats);
            EquipedWeapon.transform.SetParent(rightHand.transform);

            Debug.Log($"Equipped Weapon {weapon}");
        }
Exemplo n.º 10
0
        public void RegrowHeads()
        {
            if (TookFireDamage == false)
            {
                for (int i = 0; i < NewHeadsToGrow; i++)
                {
                    AddEquipment(EquipedWeapon.FirstOrDefault());
                    Health += (int)(MaxHealth * .08);  //add back 80% of the health it took to loose a head after growing a pair of heads
                }

                GlobalReference.GlobalValues.Notify.Room(this, null, Room, new TranslationMessage($"{SentenceDescription} grows {NewHeadsToGrow} new heads."));
            }

            NewHeadsToGrow = 0;
            TookFireDamage = false;
        }
Exemplo n.º 11
0
        private void ProcessIfHeadCutOff(IMobileObject attacker)
        {
            if (!RoundOfDamage.HeadCut &&
                RoundOfDamage.TotalDamage >= (MaxHealth / 10))
            {
                if (!TookFireDamage)
                {
                    NewHeadsToGrow += 2;                //queue 2 new heads to grow
                }

                RoundOfDamage.HeadCut = true;       //set the head to cut for this round

                //remove a head
                IWeapon weapon = EquipedWeapon.FirstOrDefault();
                RemoveEquipment(weapon);

                GlobalReference.GlobalValues.Notify.Mob(attacker, new TranslationMessage("You cut off on of the hydras heads."));
                GlobalReference.GlobalValues.Notify.Room(attacker, this, Room, new TranslationMessage("{performer} cut off on of the hydras heads."));
            }
        }
Exemplo n.º 12
0
 public bool EquipItem(Item item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     if (Items.Contains(item))
     {
         if (item is Clothing)
         {
             EquipedClothes = item as Clothing;
         }
         else if (item is Weapon)
         {
             EquipedWeapon = item as Weapon;
             Console.WriteLine("Player equipped" + EquipedWeapon.ToString());
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 13
0
    /// <summary>
    /// Unity update.
    /// </summary>
    private void Update()
    {
        var lastDirection = movePlayerScript.Direction.x;

        if (lastDirection > 0)
        {
            lastFacingDirection = 1;
        }
        else if (lastDirection < 0)
        {
            lastFacingDirection = -1;
        }

        if ((Input.GetKey(KeyCode.LeftControl) && PlayerIndex == PlayerIndex.One) ||
            (Input.GetButton(Buttons.Player2Shoot) && PlayerIndex == PlayerIndex.Two))
        {
            if (EquipedWeapon != null)
            {
                EquipedWeapon.Shoot(new Vector2(lastFacingDirection, 0));
            }
        }
    }
Exemplo n.º 14
0
        public void Draw(SpriteBatch sb)
        {
            Vector2 offset = new Vector2(ConvertUnits.ToDisplayUnits(Position.X) - FRAME_WIDTH / 2, ConvertUnits.ToDisplayUnits(Position.Y) - FRAME_HEIGHT / 2);

            srcRect = new Rectangle(frameCounter * (FRAME_WIDTH + FRAME_SEPERATION), (int)State * (FRAME_HEIGHT_SPERATION + FRAME_HEIGHT), FRAME_WIDTH, FRAME_HEIGHT);

            if (direction == PlayerDirection.LEFT)
            {
                sb.Draw(this.texture, offset, srcRect, Color.White, 0.0f, new Vector2(0, 0), 1.0f, SpriteEffects.FlipHorizontally, 1.0f);
            }
            else
            {
                Vector2 pos = ConvertUnits.ToDisplayUnits(Position);
                sb.Draw(this.texture, offset, srcRect, Color.White, 0.0f, new Vector2(0, 0), 1.0f, SpriteEffects.None, 1.0f);
            }

            if (EquipedWeapon != null)
            {
                Vector2 weaponOffset = new Vector2((ConvertUnits.ToDisplayUnits(Position.X)), ConvertUnits.ToDisplayUnits(Position.Y));
                EquipedWeapon.position = weaponOffset;
                EquipedWeapon.Draw(sb);
            }
        }
Exemplo n.º 15
0
        public void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            bool shiftDown = Keyboard.GetState().IsKeyDown(Keys.LeftShift);
            bool aDown     = Keyboard.GetState().IsKeyDown(Keys.A);
            bool dDown     = Keyboard.GetState().IsKeyDown(Keys.D);
            bool spaceDown = Keyboard.GetState().IsKeyDown(Keys.Space);

            if ((Mouse.GetState().X - parent.CameraOffset.X) > ConvertUnits.ToDisplayUnits(Position.X))
            {
                direction = PlayerDirection.RIGHT;
                EquipedWeapon.Direction = PlayerDirection.RIGHT;
            }
            else
            {
                direction = PlayerDirection.LEFT;
                EquipedWeapon.Direction = PlayerDirection.LEFT;
            }

            EquipedWeapon.Update(gameTime);

            timeCounter += gameTime.ElapsedGameTime.Milliseconds / 1000.0f;

            if (timeCounter > .04167f)
            {
                if (State != PlayerState.JUMPING || frameCounter < 3)
                {
                    frameCounter++;
                }

                timeCounter -= .04167f;
            }

            if (frameCounter >= FRAME_COUNT)
            {
                frameCounter = 0;
            }
        }
Exemplo n.º 16
0
    private void EquipedGear()
    {
        // ----------- EQUIPED GEAR UPDATE ------------- //


        // --------------------------------------------- //
        if (Input.GetKeyDown(KeyCode.Q))
        {
            inventory.Add(new Arrow());
        }


        if (EquipedWeapon != null)
        {
            if (EquipedWeapon.GetType() == typeof(Bow))
            {
                hasBowEquiped = true;
            }
            else
            {
                hasBowEquiped = false;
            }
        }
    }
 private void WeaponAttack()
 {
     EquipedWeapon?.GetComponent <IWeapon>().Attack();
 }