コード例 #1
0
 public Attack(AttackID _id, string _name, int[] _frameData, HitBox[] _hitBox)
 {
     id        = _id;
     name      = _name;
     frameData = _frameData;
     hitBox    = _hitBox;
 }
コード例 #2
0
 //Updates variables of this container
 public void UpdateAttackInfo(AttackID ID, float f, Vector2 dir, int dam)
 {
     AttackID  = ID;
     force     = f;
     direction = dir;
     damage    = dam;
 }
コード例 #3
0
    private void SetPlayerAttackState(AttackID atkId)
    {
        int atkIndex = (int)atkId;

        playerState.SetMovementState(MovementState.Attack, _frameData.attacks[atkIndex].name);
        _curAttackId = atkIndex;
    }
コード例 #4
0
 //Updates variables of this container
 public void UpdateHurtInfo(AttackInfoContainer enemyAttack)
 {
     AttackID   = enemyAttack.AttackID;
     attackType = enemyAttack.attackType;
     force      = enemyAttack.force;
     direction  = enemyAttack.direction;
 }
コード例 #5
0
    public float force;       //To determine knockback, unmodified by power ups
    //public int damage;

    //Default constructor
    public HurtInfoReceiver()
    {
        AttackID   = AttackID.Null;
        attackType = AttackType.Null;
        direction  = Vector2.zero;
        force      = 0f;
    }
コード例 #6
0
ファイル: PlayerBattle.cs プロジェクト: YBYuune/SummerStudies
    public AttackNode(AttackID id)
    {
        this.ID          = id;
        this.AttackTimer = -1.0f;
        this.IsActive    = false;

        this.nextAttacks = new List <AttackNode>();
    }
コード例 #7
0
 //Default constructor
 public AttackInfoContainer()
 {
     AttackID   = AttackID.Null;
     attackType = AttackType.Null;
     direction  = Vector2.zero;
     force      = 0f;
     damage     = 0;
 }
コード例 #8
0
 public HitBox(AttackID _id, Vector3 _position, float _radius, float _damage, float _launchPower, float _hitBoxDuration, Vector3 _launchDirection)
 {
     id              = _id;
     position        = _position;
     radius          = _radius;
     damage          = _damage;
     launchPower     = _launchPower;
     hitBoxDuration  = _hitBoxDuration;
     launchDirection = _launchDirection;
 }
コード例 #9
0
 static public float GetSpellDamage(AttackID index)
 {
     if (spellDamage.ContainsKey(index))
     {
         return((float)spellDamage[index]);
     }
     else
     {
         Debug.LogError("[SpellDB] no object with the index" + attackIDnames[(int)index]);
         return(0.0f);            // not crashed anyway
     }
 }
コード例 #10
0
        private void Update()
        {
            if (!charState.isAttacking)
            {
                // check for attack command
                if (nextAttack.IsNull())
                {
                    AttackSetID atkOrder = ReceiveAtkCommands();
                    if (atkOrder != AttackSetID.None)
                    {
                        Attack(new AttackID(atkOrder, 0));
                    }
                }
                // execute next attack
                else
                {
                    Attack(nextAttack);
                    nextAttack = AttackID.Null;
                }
                return;
            }

            // check for command for next attack
            AttackSetID atkOrder2 = ReceiveAtkCommands();

            if (atkOrder2 != AttackSetID.None)
            {
                AttackSet atkSet    = attackSets[(int)curAtk.atkSetID];
                Attack    atk       = atkSet.attacks[curAtk.atkID];
                float     atkLength = atk.animation.length;
                if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime *atkLength >= atkLength - atk.precastTime)
                {
                    // execute next attack in set
                    if (atkOrder2 == curAtk.atkSetID && curAtk.atkID + 1 < atkSet.attacks.Count)
                    {
                        nextAttack = new AttackID(atkOrder2, curAtk.atkID + 1);
                    }
                    // break set and execute first attack of new set or repeat set
                    else
                    {
                        nextAttack = new AttackID(atkOrder2, 0);
                    }
                }
            }
        }
コード例 #11
0
        protected void Attack(AttackID atkID)
        {
            if (atkID.IsNull())
            {
                return;
            }
            Attack atk = attackSets[(int)atkID.atkSetID]?.attacks[atkID.atkID];

            if (atk != null)
            {
                curAtk = atkID;
                Weapon[] weapons = GetComponentsInChildren <Weapon>();
                for (int i = 0; i < weapons.Length; i++)
                {
                    weapons[i].UsedAction = atk;
                    weapons[i].caster     = this;
                }
                atk.Execute(anim);
            }
        }
コード例 #12
0
 public AttackResult Attack(WorldEntity from, WorldEntity to, AttackID atid)
 {
     AttackResult result = AttackResult.Miss;
     if (moveDictionary.ContainsKey(atid))
     {
         result = moveDictionary[atid].ComputeAttack(from, to);
     }
     return result;
 }
コード例 #13
0
ファイル: CombatScreen.cs プロジェクト: edg3/TeamRoguelike
        public override void Update(GameTime gameTime, InputService input)
        {
            switch (comState)
            {
                case CombatState.PreCombat:
                    //TODO: pre fight stuff, priority hit if needs be
                    comState = CombatState.TurnManage;
                    break;
                case CombatState.TurnManage:
                    //Player chooses action, time progresses, eventually player chooses enxt action
                    //based on speed stat
                    if (turState == TurnState.Delay)
                    {
                        delaySpan = delaySpan.Subtract(new TimeSpan(0, 0, 0, 0, gameTime.ElapsedGameTime.Milliseconds));
                        if (delaySpan.TotalMilliseconds <= 0)
                        {
                            turState = TurnState.Waiting;
                        }
                    }
                    else if (turState == TurnState.Waiting)
                    {
                        if (_combatService.Enemy.First().Stats.HPCurrent <= 0)
                        {
                            DelayMessage = "Your enemy has fainted! You won!";
                            comState = CombatState.FinalCombat;
                            delaySpan = new TimeSpan(0, 0, 0, 0, delayMilliToAdd);
                            _combatService.Player.AddExp(_combatService.Enemy.First().Stats.Level);
                            return;
                        }
                        else if (_combatService.Player.GetPlayer().Stats.HPCurrent <= 0)
                        {
                            DelayMessage = "You have died! You lost!";
                            comState = CombatState.FinalCombat;
                            delaySpan = new TimeSpan(0, 0, 0, 0, delayMilliToAdd);
                            return;
                        }

                        bool moveHappened = false;
                        while (!moveHappened)
                        {
                            playerSpeedNext -= 1;
                            enemySpeedNext -= 1;
                            if (playerSpeedNext <= 0)
                            {
                                playerSpeedNext += _combatService.Player.GetPlayer().Stats.Get(EntityStatsContainer.AT_SPEED);
                                turState = TurnState.ChooseAction; //Players turn
                                currentMenu = 0; //Always start at the top yo
                                moveHappened = true;
                            }
                            else if (enemySpeedNext <= 0)
                            {
                                enemySpeedNext += _combatService.Enemy.First().Stats.Get(EntityStatsContainer.AT_SPEED);
                                turState = TurnState.Delay;
                                _combatService.Enemy.First().TakeCombatTurn(_combatService);
                                Delay(_combatService.Enemy.First().CombatMessage);
                                moveHappened = true;
                            }
                        }
                    }
                    else if (turState == TurnState.ChooseAction)
                    {
                        if (input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Up))
                        {
                            menuPositions[currentMenu] -= 1;
                        }
                        else if (input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Down))
                        {
                            menuPositions[currentMenu] += 1;
                        }

                        menuPositions[currentMenu] = (menuPositions[currentMenu] + menuItems[currentMenu].Length) % menuItems[currentMenu].Length;

                        if (input.Keyboard.KeyPress(Microsoft.Xna.Framework.Input.Keys.Enter))
                        {
                            switch (currentMenu)
                            {
                                case 0: //Main menu
                                    switch (menuPositions[currentMenu])
                                    {
                                        case 0: //melee default
                                            selectedAttack = AttackID.Default;
                                            currentMenu = 3; //Target select!
                                            break;
                                        case 1:
                                            //Choose skill page
                                            menuItems[4] = (from item in _combatService.Player.GetPlayer().Stats.SkillsList
                                                            select item.ToString()).ToArray();
                                            currentMenu = 4;
                                            break;
                                        case 2:
                                            break;
                                        case 3:
                                            {
                                                int roll = rndm.Next(2);
                                                if (roll == 0)
                                                {
                                                    Delay("You failed to flee!");
                                                }
                                                else
                                                {
                                                    Rock.Screen.Remove();
                                                    return;
                                                }
                                            }
                                            break;
                                    }
                                    break;
                                case 1: //Skills menu
                                    break;
                                case 2: //Items menu
                                    break;
                                case 3: //Target selection menu
                                    {
                                        //TODO: self targeting / etc
                                        AttackResult res;
                                        if (menuPositions[3] < 4)
                                        {
                                            //enemy!
                                            var target = _combatService.Enemy.Get((Party.PartySlot)menuPositions[3]);
                                            res = _combatService.Attack(_combatService.Player.GetPlayer(), target, selectedAttack);
                                        }
                                        else
                                        {
                                            //teammate
                                            var target = _combatService.Player.Get((Party.PartySlot)(menuPositions[3] - 4));
                                            res = _combatService.Attack(_combatService.Player.GetPlayer(), target, selectedAttack);
                                        }

                                        if (res == AttackResult.Hit)
                                        {
                                            Delay("Your attack hits!");
                                        }
                                        else if (res == AttackResult.Critical)
                                        {
                                            Delay("Your attack hits for a critical!");
                                        }
                                        else if (res == AttackResult.Miss)
                                        {
                                            Delay("Your attack misses!");
                                        }
                                    }
                                    break;

                                case 4:
                                    {
                                        selectedAttack = _combatService.Player.GetPlayer().Stats.SkillsList[menuPositions[4]];
                                        currentMenu = 3; //target select!
                                    }
                                    break;
                            }
                        }
                    }
                    break;
                case CombatState.FinalCombat:
                    {
                        delaySpan = delaySpan.Subtract(new TimeSpan(0, 0, 0, 0, gameTime.ElapsedGameTime.Milliseconds));
                        if (delaySpan.TotalMilliseconds <= 0)
                        {
                            if (_combatService.Player.MessageStack.Count > 0)
                            {
                                DelayMessage = _combatService.Player.MessageStack.Pop();
                                delaySpan = new TimeSpan(0, 0, 0, 0, delayMilliToAdd * 2);
                            }
                            else
                            {
                                Rock.Screen.Remove();
                                return;
                            }
                        }
                    }
                    break;
            }
        }