Exemplo n.º 1
0
        public override void Simulate(float dt, Input_t input)
        {
            base.Simulate(dt, input);


            if (!alive)
            {
                decayTime -= Time.deltaTime;
                if (decayTime <= 0)
                {
                    Destroy();
                }
                return;
            }

            if (canAttack)
            {
                for (int i = 0; i < AttackState.MaxAttackTypes; i++)
                {
                    var attackState = input.attacks[i];
                    if (attackState != null)
                    {
                        Weapon w = GetInventorySlot(attackState.weaponIndex) as Weapon;
                        if (w != null)
                        {
                            if (input.IsPressed(attackState.inputState))
                            {
                                w.Charge(dt, 1);
                            }
                            else
                            {
                                w.chargeTime = 0;
                            }

                            if (input.JustReleased(attackState.inputState))
                            {
                                w.Attack(this, attackState.attackIndex);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (var weapon in getInventory())
                {
                    Weapon w = weapon as Weapon;
                    if (w != null)
                    {
                        w.chargeTime = 0;
                    }
                }
            }
        }
Exemplo n.º 2
0
        override public void Simulate(float dt, Input_t input)
        {
            if (!alive)
            {
                return;
            }

            if (tradePartner != null)
            {
                var diff = tradePartner.position - position;
                if (diff.magnitude > data.tradePartnerCancelDistance)
                {
                    SetTradePartner(null);
                }
            }

            if (input.JustPressed(InputType.Swap))
            {
                if (tradePartner != null)
                {
                    SetTradePartner(null);
                }
                else if (mount != null)
                {
                    SetMount(null);
                }
                else
                {
                    SwapWeapons();
                }
            }


            if (input.JustPressed(InputType.Interact))
            {
                Interact();
            }
            bool   isCasting = false;
            Weapon itemLeft, itemRight;

            GetEquippedWeapons(out itemLeft, out itemRight);
            if (canAttack)
            {
                if (itemLeft != null)
                {
                    if (itemLeft.CanCast())
                    {
                        if (input.JustReleased(InputType.AttackLeft))
                        {
                            if (itemLeft.chargeTime < itemLeft.data.jabChargeTime)
                            {
                                itemLeft.Attack(this, 0);
                                isCasting = true;
                            }
                        }
                    }
                }
                if (itemRight != null)
                {
                    if (itemRight.CanCast())
                    {
                        if (input.JustReleased(InputType.AttackRight))
                        {
                            itemRight.Attack(this, 0);
                            isCasting = true;
                        }
                    }
                }
                if (itemLeft != null)
                {
                    if (itemLeft.CanCast() && input.IsPressed(InputType.AttackLeft))
                    {
                        itemLeft.Charge(dt, 0);
                        isCasting = true;
                    }
                    else
                    {
                        if (itemLeft.attackHand == 0)
                        {
                            itemLeft.chargeTime = 0;
                        }
                    }
                }
                if (itemRight != null)
                {
                    if (itemRight.CanCast() && input.IsPressed(InputType.AttackRight))
                    {
                        itemRight.Charge(dt, 1);
                        isCasting = true;
                    }
                    else
                    {
                        if (itemRight.attackHand == 1)
                        {
                            itemRight.chargeTime = 0;
                        }
                    }
                }
            }

            attackTargetPreview = GetAttackTarget(yaw, 20, 360 * Mathf.Deg2Rad, null);

            if (isCasting)
            {
                SetTradePartner(null);
            }

            base.Simulate(dt, input);
            UpdateStats(dt);
        }