Inheritance: MonoBehaviour
    public void AddCombatant(Combatant combatant)
    {
        List<SkillButton> buttons;
        _buttons.TryGetValue(combatant, out buttons);

        if (buttons == null) {
            buttons = new List<SkillButton>();

            foreach (ISkill skill in combatant.Skills) {
                SkillButton newButton = CreateButton(skill);
                buttons.Add(newButton);
            }

            _buttons[combatant] = buttons;
        } else {
            foreach (ISkill skill in combatant.Skills.Except(buttons.Select(b => b.Skill))) {
                SkillButton newButton = CreateButton(skill);
                buttons.Add(newButton);
            }
        }

        if (_combatant == null) {
            _combatant = combatant;
            _page = SetPage(0);
        }
    }
Beispiel #2
0
    double CalcDamage(Combatant attacker, Combatant defender, Attack attack)
    {
        System.Random gen = new System.Random();
        double crit = 1.0;
        double attackPower = 0.0;
        double defensePower = 0.0;

        //does hit
        if(gen.NextDouble() * 100 > (attack.accuracy + attacker.perception))
        {
            return 0.0;
        }
        //is crit

        if(gen.NextDouble()*100 < (0.05+0.02 * attacker.luck))
        {
            crit = 1.5;
        }
        //do damage
        attackPower = attack.power * attacker.strength;
        defensePower = defender.defense + defender.getArmorValue();

        //return

        return (attackPower / defensePower) * crit;
    }
 public ThreadedCalculateAIOrder(Combatant combatant, MapManager map)
 {
     this.combatant = combatant;
     this.map = map;
     thread = new System.Threading.Thread(Calculate);
     thread.Start();
 }
    private void OnSkillActivated(Combatant combatant, ISkill skill)
    {
        // Unbind delegates from old skill
        if (_ranged != null) {
            _ranged.TargetChanged -= OnTargetChanged;
        } else if (_directional != null) {
            _directional.DirectionChanged -= OnDirectionChanged;
        }

        // Figure out origin from ActionQueue
        PawnAction lastAction = _combatant.LastAction;
        _origin = (lastAction == null) ? _combatant.Position : lastAction.PostRunPosition;

        // Figure out what kind of skill it is
        _ranged = skill as RangedSkill;
        _directional = skill as DirectionalSkill;

        // Bind delegates to new skill
        if (_ranged != null) {
            _ranged.TargetChanged += OnTargetChanged;
            OnTargetChanged(_ranged.Target);
        } else if (_directional != null) {
            _directional.DirectionChanged += OnDirectionChanged;
            OnDirectionChanged(_directional.Direction);
        }
    }
 public SquadUnit(Combatant unit)
 {
     Unit = unit;
     Goal = new StateOffset();
     IsManual = true;
     Planner = new Planner(StateOffset.Heuristic);
 }
        public void StationaryMelee()
        {
            Board board = new Board(BoardCommon.GRID_12X8);
            Combatant attacker = new Combatant("Attacker", board, new Point(5, 4));
            Combatant defender = new Combatant("Defender", board, new Point(7, 4));
            board.AddPawn(attacker);
            board.AddPawn(defender);

            attacker.Health = 10;
            defender.Health = 10;

            attacker.BaseStats = new Stats() {
                Attack = 10,
                Stamina = 10
            };

            MeleeAttackSkill attack = new MeleeAttackSkill(attacker, new Point[] { Point.Right, 2 * Point.Right }) {
                ActionPoints = 3
            };
            attack.SetDirection(CardinalDirection.East);

            attacker.AddSkill(attack);
            attack.Fire();

            board.BeginTurn();
            Assert.AreEqual(10, attacker.ActionPoints);

            board.Turn();
            Assert.AreEqual(0, defender.Health);
            Assert.AreEqual(7, attacker.ActionPoints);
        }
 public MoveAction(Combatant owner, Point start, Point end, bool isContinuous)
     : base(owner)
 {
     _start = start;
     _end = end;
     _isContinuous = isContinuous;
 }
 private void OnSkillDeactivated(Combatant combatant, ISkill skill)
 {
     _gridField.ClearPoints();
     _gridField.RebuildMesh();
     _ranged = null;
     _directional = null;
 }
Beispiel #9
0
    /*
    ============================================================================
    Condition functions
    ============================================================================
    */
    public void ApplyCondition(Combatant c)
    {
        if(DataHolder.BattleSystem().IsActiveTime())
        {
            c.timeBar = this.timebar;
            if(c.timeBar > DataHolder.BattleSystem().maxTimebar)
            {
                c.timeBar = DataHolder.BattleSystem().maxTimebar;
            }
        }

        for(int i=0; i<this.setStatus.Length; i++)
        {
            if(this.setStatus[i])
            {
                c.status[i].SetValue(this.status[i], true, false, false);
            }
        }

        for(int i=0; i<this.effect.Length; i++)
        {
            if(SkillEffect.ADD.Equals(this.effect[i]))
            {
                c.AddEffect(i, c);
            }
            else if(SkillEffect.REMOVE.Equals(this.effect[i]))
            {
                c.RemoveEffect(i);
            }
        }
    }
        /// <summary>
        /// Contruct a new MeleeAttackSkill.
        /// </summary>
        /// <param name="attacker">Reference to Attacking Combatant</param>
        /// <param name="areaOfEffect">
        /// Collection of Point offsets indicating which tiles around the attacker are affected by the attack.
        /// These offsets are rotated based on this skill's Direction attribute, and are defined based on the
        /// attacker facing east.
        /// </param>
        public MeleeAttackSkill(Combatant attacker, IEnumerable<Point> areaOfEffect = null)
            : base(attacker, "Melee Attack", "Attack an adjacent space")
        {
            if (areaOfEffect == null) {
                _areaOfEffect = new List<Point>();
            } else {
                _areaOfEffect = new List<Point>(areaOfEffect);
            }

            for (CardinalDirection d = CardinalDirection.East; d < CardinalDirection.Count; d++) {
                _transforms[d] = new Point[_areaOfEffect.Count];
            }

            for (int i = 0; i < _areaOfEffect.Count; i++) {
                Point east = _areaOfEffect[i];
                Point south = new Point(-east.Y, east.X);
                Point west = new Point(-east.X, -east.Y);
                Point north = new Point(east.Y, -east.X);

                _transforms[CardinalDirection.East][i] = east;
                _transforms[CardinalDirection.South][i] = south;
                _transforms[CardinalDirection.West][i] = west;
                _transforms[CardinalDirection.North][i] = north;

                _fullAreaOfEffect.Add(east);
                _fullAreaOfEffect.Add(south);
                _fullAreaOfEffect.Add(west);
                _fullAreaOfEffect.Add(north);
            }
        }
 public void StartThreadToFindTilesInRange(Combatant combatant, MapManager map)
 {
     this.combatant = combatant;
     this.map = map;
     thread = new System.Threading.Thread(FindTilesInRange);
     thread.Start();
 }
Beispiel #12
0
    public void SetCombatant(Combatant combatant)
    {
        this.combatant = combatant;

        leftPane = CharacterPane.FindLeftPane();
        EnablePane();
        CreateBattleOrder();
    }
 public CharacterController(Combatant owner)
 {
     _owner = owner;
     _approachDecision = new Decision.ApproachMeleeRange(_owner);
     _planner.AddDecision(_approachDecision);
     _attackDecision = new Decision.AttackWithMelee(_owner);
     _planner.AddDecision(_attackDecision);
 }
Beispiel #14
0
    public void SetCombatant(Combatant combatant)
    {
        Debug.Log("setting combant -" + combatant + "-");
        this.combatant = combatant;

        leftPane = CharacterPane.FindLeftPane();
        EnablePane();
    }
    public void Initialize(Combatant combatant, BoardGridField gridField)
    {
        _combatant = combatant;
        _combatant.SkillActivated += OnSkillActivated;
        _combatant.SkillDeactivated += OnSkillDeactivated;

        _gridField = gridField;
    }
Beispiel #16
0
 public BattleAction(AttackSelection t, Combatant u, int tID, int id, int ul)
 {
     this.type = t;
     this.user = u;
     this.targetID = tID;
     this.useID = id;
     this.useLevel = ul;
 }
 public override Queue<Action> GetActions(Combatant me, List<Combatant> allies, List<Combatant> enemies)
 {
     Queue<Action> actions = new Queue<Action>();
     actions.Enqueue(new ActionInfo(me.combatantName + " uses Taunt!"));
     actions.Enqueue(new ActionBuff(me,"Taunt", 1));
     actions.Enqueue(new ActionPauseForFrames(60));
     actions.Enqueue(new ActionHideInfo());
     return actions;
 }
Beispiel #18
0
 public void pickUp(Combatant currentCombatant)
 {
     this.currentCombatant = currentCombatant;
     transform.rotation = currentCombatant.transform.rotation;
     rb.isKinematic = true;
     collider.enabled = false;
     pickedUp = true;
     onPickUp();
 }
Beispiel #19
0
    //Combatant player;
    //Combatant enemy;

    public void StartCombat(Combatant player, Combatant enemy)
    {
        /*
        this.player = player;
        this.enemy = enemy;
        player.Initialize();
        enemy.Initialize();
        */
    }
Beispiel #20
0
    public void PopulateOptions(Combatant combatant)
    {
        //options = combatant.Options;
        string message = string.Join("\n", options.ToArray());
        headerText.text = combatant.gameObject.name;
        optionsText.text = message;

        currentSelection = options [0];
    }
 public void Populate(Combatant combatant)
 {
     if (combatant == null) {
         nameText.text = "--";
         hpText.text = "-/-";
         return;
     }
     nameText.text = combatant.name;
     hpText.text = combatant.Stats.CurrentHealth + " / " + combatant.Stats.MaxHealth;
 }
    /// <summary>
    /// Adds a Combatant to this TimelineController, creating a new Timeline keyed to that Combatant, and binding
    /// the relevant events.
    /// </summary>
    /// <param name="combatant">Combatant to add</param>
    public void AddCombatant(Combatant combatant)
    {
        if (_timelines.Find(t => t.Source == combatant) == null) {
            _timelines.Add(new Timeline(combatant));

            combatant.SkillActivated += OnSkillActivated;
            combatant.SkillFired += OnSkillFired;
            combatant.ActionsCleared += OnActionsCleared;
        }
    }
Beispiel #23
0
 /*
 ============================================================================
 In-game functions
 ============================================================================
 */
 public void Init(Animation animation, Combatant c)
 {
     if(this.name != "" && animation[this.name] != null)
     {
         animation[this.name].layer = layer;
         if(this.setSpeed && c != null)
         {
             animation[this.name].speed = DataHolder.Formula(this.speedFormula).Calculate(c, c)*GameHandler.AnimationFactor;
         }
     }
 }
 void NextTurn()
 {
     if (activeCombatant == null) {
         activeCombatant = combatants[0];
     } else {
         int i = combatants.IndexOf(activeCombatant);
         i = (i + 1) % combatants.Count;
         activeCombatant = combatants[0];
     }
     //menu.PopulateOptions(activeCombatant);
 }
 public ApproachMeleeRange(Combatant source)
     : base(source)
 {
     _source = (Combatant)source;
     if ((_walk = _source.GetSkill<WalkSkill>()) == null) {
         throw new ArgumentException("source", "Combatant " + source.Name + " doesn't have a Walk skill");
     }
     if ((_melee = _source.GetSkill<MeleeAttackSkill>()) == null) {
         throw new ArgumentException("source", "Combatant " + source.Name + " doesn't have a Melee Attack skill");
     }
 }
 /*
 ============================================================================
 Animation handling functions
 ============================================================================
 */
 public void SetAnimationLayers(Combatant c)
 {
     Animation a = c.GetAnimationComponent();
     if(a != null)
     {
         for(int i=0; i<this.animation.Length; i++)
         {
             this.animation[i].Init(a, c);
         }
     }
 }
    public void RemoveCombatant(Combatant combatant)
    {
        int index = _timelines.FindIndex(t => t.Source == combatant);
        if (index != -1) {
            _timelines.RemoveAt(index);

            combatant.SkillActivated -= OnSkillActivated;
            combatant.SkillFired -= OnSkillFired;
            combatant.ActionsCleared -= OnActionsCleared;
        }
    }
Beispiel #28
0
 private bool BattleAttack(Combatant c)
 {
     bool ok = false;
     if(this.combatant is Enemy)
     {
         c.AddAction(new BattleAction(
                 AttackSelection.ATTACK, c, this.combatant.battleID, -1, 0));
         ok = true;
     }
     return ok;
 }
Beispiel #29
0
 void Start()
 {
     CombatantClick cc = (CombatantClick)this.transform.root.GetComponent(typeof(CombatantClick));
     if(cc == null)
     {
         cc = (CombatantClick)this.transform.root.GetComponentInChildren(typeof(CombatantClick));
     }
     if(cc != null)
     {
         this.combatant = cc.combatant;
     }
 }
        public DamageMessage(Combatant target, int amount, Combatant source = null)
        {
            Target = target;
            Source = source;
            Amount = amount;

            if (Source != null) {
                Text = Source.Name + " inflicted " + amount + " damage on " + Target.Name;
            } else {
                Text = Target.Name + " took " + amount + " damage";
            }
        }
Beispiel #31
0
        protected override void OnStart()
        {
            //CombatEventReceiver.Instance.OnCombatEventTiming(ReactionEvent, eCombatEventTiming.ON_REACTION_START);

            StartActionState();

            if (ReactionEvent.IsMiss)
            {
                Combatant.FXHelper.ReportAttackResult(MoveEditor.AttackResult.Missed);
            }
            else if (ReactionEvent.IsBlocked)
            {
                Combatant.FXHelper.ReportAttackResult(MoveEditor.AttackResult.Blocked);
            }
            else
            {
                Combatant.FXHelper.ReportAttackResult(MoveEditor.AttackResult.Hit);
            }

            long hp = Combatant.GetHP() - ReactionEvent.Damage;

            Combatant.SetHP(hp);
            //CombatInfoData.GetInstance().Log("damage applyed, hp = " + hp + ", source = " + ReactionEvent.Sender + ", target = " + ReactionEvent.Target);
            //if(ReactionEvent.Damage>0)
            //	EventManager.instance.Raise(new CombatHitDamageEvent(Combatant.gameObject, ReactionEvent.Damage, ReactionEvent.Show, ReactionEvent.Shield));

            // EB.Debug.Log(string.Format("ReactionEventState.OnStart: {0} start action {1}", Combatant.myName, Combatant.ActionState.GetType().ToString()));

            if (!Combatant.IsAlive())
            {
                //CombatSkillEvent skill_event = CombatEventReceiver.Instance.FindEventTree(ReactionEvent).Parent.Event as CombatSkillEvent;
                //if (CombatEventReceiver.Instance.IsLastSkill(skill_event))
                //{
                //    CombatEventReceiver.Instance.PlayRadialBlurEffect(Combatant);
                //}
            }
        }
Beispiel #32
0
        private void UpdateBattleStateEnemyTurn()
        {
            var combatants = (from c in BattleBoard.Characters where c.Faction == 1 && c.CanMove select c).ToArray();

            if (combatants.Any())
            {
                // find first character that can move
                _selectedCharacter = combatants[0];

                // find the optimal location
                var decision = _commander.CalculateAction(_selectedCharacter);

                // create move command to that location
                var moveCommand = new Command
                {
                    Ability   = Ability.Factory(Game, "move"),
                    Character = _selectedCharacter,
                    Target    = decision.Destination
                };

                QueuedCommands.Add(moveCommand);

                if (decision.Command.Ability != null)
                {
                    QueuedCommands.Add(decision.Command);
                }

                ExecuteQueuedCommands();

                return;
            }

            ExecuteQueuedCommands();

            // all enemy players have moved / attacked
            ChangeFaction(0);
        }
Beispiel #33
0
        public override void Update()
        {
            base.Update();

            if (skipmove)
            {
                Stop();
                return;
            }

            MoveController.CombatantMoveState move_state = Combatant.GetMoveState();
            int state_hash = Combatant.MoveController.GetCurrentAnimHash();
            AnimatorStateInfo state_info = Combatant.MoveController.GetCurrentStateInfo();

            if (move_state != MoveController.CombatantMoveState.kAttackTarget)
            {
                EB.Debug.LogError("move state not match");
                Stop();
                return;
            }

            if (state_hash != state_info.fullPathHash)
            {
                EB.Debug.Log("SkillActionState.Update: animator state not ready, {0} != {1}", state_hash.ToString(), state_info.fullPathHash.ToString());
                return; //but we do not need to stay here
            }

            float end_time = 1.0f - timeEpsilon;

            if (state_info.normalizedTime > end_time && NormalizedTime > end_time)
            {
                End();
                return;
            }

            NormalizedTime = state_info.normalizedTime;
        }
Beispiel #34
0
        public void SetTurn(Combatant incoming)
        {
            if (_bank.Combat.Round == 0)
            {
                return;
            }

            if (incoming.TurnTaken)
            {
                return;
            }

            var current = _bank.Combat.Turn;

            if (!incoming.IsActive)
            {
                return;
            }

            _affect.CheckExpirationOnTurn(incoming, current);

            if (current != null)
            {
                current.TurnTaken = true;
                current.IsTurn    = false;
            }

            _bank.Combat.Turn = incoming;
            incoming.IsTurn   = true;

            if (OnCombatantChanged != null)
            {
                OnCombatantChanged(this, new CombatantChangedEventArgs());
            }

            Notify();
        }
Beispiel #35
0
    public string Use(Combatant user, Combatant target)
    {
        int damage = 0;

        switch (SkillName)
        {
        case SkillName.Mash:
            damage    = DamageCalculation(user, target, Amount);
            user.Act -= Cost;
            return(string.Format("Player used Mash, did [{0}] damage!", damage));

        case SkillName.LeanIn:
            user.Act -= Cost;
            user.Act += Amount;
            return(string.Format("Player used LeanIn,  +[{0}] speed!", Amount));

        case SkillName.Grind:
            damage    = DamageCalculation(user, target, Amount);
            user.Act -= Cost;
            return(string.Format("Player used Grind, did [{0}] damage!", damage));
        }

        return(string.Empty);
    }
Beispiel #36
0
        public void DrawCharacters(SpriteBatch spritebatch, Party party)
        {
            for (int i = 0; i < party.ActiveMembers.Count; i++)
            {
                Vector2   start = new Vector2(40, i * 150 + 120);
                Combatant comb  = party.ActiveMembers[i];

                spritebatch.Draw(comb.Face, new Rectangle((int)start.X, (int)start.Y, 92, 92), Color.White);

                spritebatch.DrawString(spriteFont, comb.Name, new Vector2(start.X + 100, start.Y),
                                       Color.White);

                spritebatch.DrawString(spriteFont, "LV " + comb.Level, new Vector2(start.X + 190, start.Y),
                                       Color.White);

                spritebatch.DrawString(spriteFont, "HP", new Vector2(start.X + 100, start.Y + 30), Color.White);
                spritebatch.DrawString(spriteFont, "MP", new Vector2(start.X + 100, start.Y + 50), Color.White);
                spritebatch.DrawString(spriteFont, "EXP", new Vector2(start.X + 100, start.Y + 70), Color.White);

                spritebatch.Draw(emptyBar, new Rectangle((int)start.X + 140, (int)start.Y + 35, 80, 10), Color.White);
                spritebatch.Draw(emptyBar, new Rectangle((int)start.X + 140, (int)start.Y + 55, 80, 10), Color.White);
                spritebatch.Draw(emptyBar, new Rectangle((int)start.X + 140, (int)start.Y + 75, 80, 10), Color.White);

                int curHP  = GetBarFill(comb.HP, comb.MaxHP);
                int curMP  = GetBarFill(comb.MP, comb.MaxMP);
                int curEXP = GetBarFill(18, 100);

                spritebatch.Draw(fullBar, new Rectangle((int)start.X + 140, (int)start.Y + 35, curHP, 10), Color.White);
                spritebatch.Draw(fullBar, new Rectangle((int)start.X + 140, (int)start.Y + 55, curMP, 10), Color.White);
                spritebatch.Draw(fullBar, new Rectangle((int)start.X + 140, (int)start.Y + 75, curEXP, 10), Color.White);

                spritebatch.DrawString(smallFont, comb.HP + "/" + comb.MaxHP, new Vector2(start.X + 223, start.Y + 32), Color.Red);
                spritebatch.DrawString(smallFont, comb.MP + "/" + comb.MaxMP, new Vector2(start.X + 223, start.Y + 52), Color.Red);
                spritebatch.DrawString(smallFont, "18/100", new Vector2(start.X + 223, start.Y + 72), Color.Red);
            }
        }
Beispiel #37
0
        /// <summary>
        /// Cast this ability. The <param name="source">source</param> is the <see cref="Combatant" /> which is responsible for casting the spell.
        /// The spell can have one or more <param name="targets">targets</param>.
        /// </summary>
        /// <param name='source'>
        /// Source.
        /// </param>
        /// <param name='targets'>
        /// Targets.
        /// </param>
        /// <param name='modifiers'>
        /// Modifiers.
        /// </param>
        /// <param name='resetTurnTimer'>
        /// If set to <c>true</c> reset turn timer.
        /// </param>
        public void Use(Combatant source, IEnumerable <Combatant> targets, AbilityModifiers modifiers)
        {
            bool canUse = true;

            if (!modifiers.CostsNothing)
            {
                if (source.MP >= MPCost)
                {
                    source.UseMP(MPCost);
                }
                else
                {
                    canUse = false;
                }
            }

            BattleEvent e = null;

            if (canUse)
            {
                e = new AbilityEvent(this, modifiers, source, targets.ToArray());
            }
            else
            {
                e = new AbilityFailEvent(source, this, modifiers.ResetTurnTimer);
            }

            if (modifiers.CounterAttack)
            {
                source.CurrentBattle.EnqueueCounterAction(e);
            }
            else
            {
                source.CurrentBattle.EnqueueAction(e);
            }
        }
Beispiel #38
0
        /// <summary>
        /// Move an entity
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="destination"></param>
        public void MoveEntity(Combatant entity, Coord destination)
        {
            if (!WalkabilityMap[destination])
            {
                throw new Exception();
            }

            if (EntityMap[entity.Coordinate] == null)
            {
                throw new Exception();
            }


            EntityMap[entity.Coordinate].Remove(entity);
            WalkabilityMap[entity.Coordinate] = EntityMap[entity.Coordinate].IsPassable;

            // clean up seems not needed
            //if (!EntityMap[entity.Coordinate].Has<AdventureEntity>())
            //{
            //    EntityMap[entity.Coordinate] = null;
            //}

            if (EntityMap[destination] == null)
            {
                EntityMap[destination] = new AdventureEntityContainer();
            }

            EntityMap[destination].Add(entity);
            WalkabilityMap[destination] = EntityMap[destination].IsPassable;

            entity.Coordinate = destination;

            entity.FovCoords = CalculateFoV(entity.Coordinate, entity is Mogwai);

            Adventure.Enqueue(AdventureLog.EntityMoved(entity, destination));
        }
Beispiel #39
0
 // Add a combatant to the battle
 public void AddCombatant(Combatant c)
 {
     m_combatants.Add(c);        // Add to the list
     m_numberOfCombatants++;     // Increment the count
     if (c.isPlayer)
     {
         SetButtonText();               // Set the button text only if the passed in combatant is the player
         if (m_numberOfCombatants == 1) // if the player is the first combatant
         {
             m_canAct = true;           // Allow the player to act
             ActivateButtons(m_canAct); // Set the buttons to be interactable
         }
     }
     else
     {
         if (m_numberOfCombatants == 1)  // if c is the first combatant and not the player start the game
         {
             StartCoroutine(WaitFor(2)); // NOTE: This needs to be done in a better way.  Need to start when all combatants are added
             m_canAct = false;           // Disallow the player to act
             ActivateButtons(m_canAct);  // Set the buttons to be non-interactable
         }
     }
     SetDeafultTextDisplay();    // Set the Default text display
 }
Beispiel #40
0
    protected override void OnApplyEffect(Combatant primaryTarget, AbilityDetails details)
    {
        if (details.command.diagonal)
        {
            Debug.LogWarning("Knockback cannot be applied on abilities with diagonal reach");
            return;
        }

        GridPos performerPos = details.performer.Point;

        foreach (GridObject target in details.targets)
        {
            int xDelta = 0;
            int yDelta = 0;

            GridPos defPos = target.Point;
            if (defPos.x < performerPos.x)
            {
                xDelta = -distance;
            }
            else if (defPos.x > performerPos.x)
            {
                xDelta = +distance;
            }
            else if (defPos.y < performerPos.y)
            {
                yDelta = -distance;
            }
            else if (defPos.y > performerPos.y)
            {
                yDelta = +distance;
            }

            KnockBack(target, defPos, xDelta, yDelta);
        }
    }
Beispiel #41
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (player.inCombat == false)         //Battle field class follows the player
     {
         transform.position = player.transform.position + offset;
     }
     if (player.inCombat == true && player.waitingForFader == false)
     {
         int enemiesInFight = 0;
         for (int i = 0; i < combatantsInFight.Count; i++)
         {
             Combatant checkedFile = combatantsInFight[i].GetComponent("Combatant") as Combatant;
             if (checkedFile.isPC == false)
             {
                 enemiesInFight++;
             }
         }
         if (enemiesInFight == 0 && initiativeList[0].character.isReadyToEndTurn() == true)             //If there are no enemies left, end the combat
         {
             activateEndCombatMenu = true;
             //CompleteCombat();
         }
     }
 }
        public void UseAbility(int index, double quantity, Combatant target)
        {
            var unit         = this.game.PlayOrder.Peek();
            var abilityStats = this.mainGame.Derivates.Of(unit.Owner).DesignStats[unit.Ships.Design].Abilities[index];
            var chargesLeft  = quantity;
            var spent        = 0.0;

            if (!abilityStats.TargetShips || Methods.HexDistance(target.Position, unit.Position) > abilityStats.Range)
            {
                return;
            }

            if (abilityStats.IsInstantDamage)
            {
                spent = this.doDirectAttack(unit, abilityStats, quantity, target);
            }

            spent = Math.Min(spent, quantity);
            unit.AbilityCharges[index] -= spent;
            if (!double.IsInfinity(unit.AbilityAmmo[index]))
            {
                unit.AbilityAmmo[index] -= spent;
            }
        }
        private void RefreshCombatants()
        {
            var player = FFXIV.Instance.GetPlayer();

            if (player != null)
            {
                this.player = player;
            }

            var party = FFXIV.Instance.GetPartyList();

            if (party != null)
            {
                var newList = new List <Combatant>(party);

                if (newList.Count < 1 &&
                    !string.IsNullOrEmpty(this.player.Name))
                {
                    newList.Add(this.player);
                }

                this.partyList = newList;
            }
        }
Beispiel #44
0
    //JSON
    public void LoadCombatantData(int id)
    {
        string filePath = Application.dataPath + gameDataProjectFilePath + id.ToString() + ".json";

        if (File.Exists(filePath))
        {
            string    dataAsJson    = File.ReadAllText(filePath);
            Combatant jsonCombatant = JsonUtility.FromJson <Combatant>(dataAsJson);

            m_refId       = jsonCombatant.jRefId;
            m_name        = jsonCombatant.jName;
            m_description = jsonCombatant.jDescription;
            m_maxhp       = jsonCombatant.jMaxhp;
            m_maxap       = jsonCombatant.jMaxap;
            //m_currenthp = jsonCombatant.jCurrenthp;
            //m_currentap = jsonCombatant.jCurrentap;
            m_deckId = jsonCombatant.jDeckId;
        }
        else
        {
            Combatant jsonCombatant = new Combatant();
            Debug.Log("json failed");
        }
    }
Beispiel #45
0
        public void GetInput()
        {
            ConsoleKeyInfo key = new ConsoleKeyInfo();

            if (_gameState == GameState.ChoosingClass)
            {
                ConsoleKey[] acceptableKeys = { ConsoleKey.D1, ConsoleKey.D2, ConsoleKey.D3, ConsoleKey.D4 };
                bool         finished       = false;
                const int    baseHealth     = 500;

                while (!finished)
                {
                    key = Console.ReadKey(true);
                    if (acceptableKeys.Contains(key.Key))
                    {
                        finished = true;
                    }
                }

                switch (key.Key)
                {
                case ConsoleKey.D1:
                    _playerCombatant = new Combatant(random: _random)
                    {
                        MaxHealth = baseHealth + 80,
                        Attack    = 6,
                        Defence   = 9,
                        Speed     = 2,
                        Name      = "Tank",
                        Moves     = new List <Move>()
                        {
                            MoveContainer.Punch,
                            MoveContainer.BodySlam,
                            MoveContainer.Toughen,
                            MoveContainer.UltimateSlam
                        }
                    };
                    break;

                case ConsoleKey.D2:
                    _playerCombatant = new Combatant(random: _random)
                    {
                        MaxHealth = baseHealth + 40,
                        Attack    = 8,
                        Defence   = 3,
                        Speed     = 10,
                        Name      = "Ninja",
                        Moves     = new List <Move>()
                        {
                            MoveContainer.Punch,
                            MoveContainer.BodySlam,
                            MoveContainer.Toughen,
                            MoveContainer.Shinobi
                        }
                    };
                    break;

                case ConsoleKey.D3:
                    _playerCombatant = new Combatant(random: _random)
                    {
                        MaxHealth = baseHealth + 60,
                        Attack    = 8,
                        Defence   = 5,
                        Speed     = 6,
                        Name      = "Mage",
                        Moves     = new List <Move>()
                        {
                            MoveContainer.Punch,
                            MoveContainer.BodySlam,
                            MoveContainer.Toughen,
                            MoveContainer.Fireball
                        }
                    };
                    break;

                case ConsoleKey.D4:
                    _playerCombatant = new Combatant(random: _random)
                    {
                        MaxHealth = baseHealth + 90,
                        Attack    = 9,
                        Defence   = 2,
                        Speed     = 5,
                        Name      = "Dark Mage",
                        Moves     = new List <Move>()
                        {
                            MoveContainer.Punch,
                            MoveContainer.BodySlam,
                            MoveContainer.Toughen,
                            MoveContainer.LifeDrain
                        }
                    };
                    break;
                }
                const int baseMaximumMoves = 0;
                _maximumMoves = 10 + _playerCombatant.Speed;
            }

            else if (_gameState == GameState.Overworld)
            {
                ConsoleKey[] acceptableKeys = { ConsoleKey.W, ConsoleKey.A, ConsoleKey.S, ConsoleKey.D };
                bool         finished       = false;

                while (!finished)
                {
                    key = Console.ReadKey(true);
                    if (acceptableKeys.Contains(key.Key))
                    {
                        finished = true;
                    }
                }

                switch (key.Key)
                {
                case ConsoleKey.W:
                    _overworldGrid.MoveCharacter(0, -1);
                    _moves++;
                    _overworldGrid.Display();
                    Console.WriteLine($"Moves left: {_maximumMoves - _moves}");
                    break;

                case ConsoleKey.A:
                    _overworldGrid.MoveCharacter(-1, 0);
                    _moves++;
                    _overworldGrid.Display();
                    Console.WriteLine($"Moves left: {_maximumMoves - _moves}");
                    break;

                case ConsoleKey.S:
                    _overworldGrid.MoveCharacter(0, 1);
                    _moves++;
                    _overworldGrid.Display();
                    Console.WriteLine($"Moves left: {_maximumMoves - _moves}");
                    break;

                case ConsoleKey.D:
                    _overworldGrid.MoveCharacter(1, 0);
                    _moves++;
                    _overworldGrid.Display();
                    Console.WriteLine($"Moves left: {_maximumMoves - _moves}");
                    break;
                }
            }

            else
            {
                ConsoleKey[] acceptableKeys = { ConsoleKey.D1, ConsoleKey.D2, ConsoleKey.D3, ConsoleKey.D4 };
                bool         finished       = false;

                while (!finished)
                {
                    key = Console.ReadKey(true);
                    if (acceptableKeys.Contains(key.Key))
                    {
                        finished = true;
                    }
                }

                _battleController.SetPlayerAttack(key.Key switch
                {
                    ConsoleKey.D1 => 0,
                    ConsoleKey.D2 => 1,
                    ConsoleKey.D3 => 2,
                    ConsoleKey.D4 => 3
                });
Beispiel #46
0
 public RemoteNetworkedPVPMover(EngineRoomNetworkManager ernm, bool isServer, Combatant toOverwrite)
 {
     ernm.AttachToListenerMover(this, isServer);
     this.toOverwrite = toOverwrite;
 }
 void Start()
 {
     playerScript = player.GetComponent <Combatant>();
     enemyScript  = enemy.GetComponent <Combatant>();
 }
        private void CombatantAdded(object Combatant)
        {
            Combatant cmb = (Combatant)Combatant;

            this.combatantTable[cmb.ID] = cmb;
        }
Beispiel #49
0
 public DefaultBattleAI(Combatant combatant, Combatant initialTarget)
 {
     Combatant = combatant;
     RB        = combatant.GetComponent <Rigidbody2D>();
     Target    = initialTarget;
 }
Beispiel #50
0
 public DefaultBattleAI(Combatant combatant)
 {
     Combatant = combatant;
     RB        = combatant.GetComponent <Rigidbody2D>();
 }
    public void nextTurn()
    {
        isFirstTurn = false;
        this.actionsMenu.SetActive(false);
        this.playerHealthName.SetActive(false);
        this.playerAvatar.SetActive(false);
        this.playerManaName.SetActive(false);
        this.enemyUnitsMenu.SetActive(false);
        playerAttack = false;
        GameObject[] remainEnemyUnit = GameObject.FindGameObjectsWithTag("Enemy");

        if (remainEnemyUnit.Length == 0)
        {
            //        GameObject[] playerObject = GameObject.FindGameObjectsWithTag("PlayerUnit");
            //        for (var i = 0; i < playerObject.Length; i++) {
            //if (playerObject[i].gameObject.name == "Player1") {
            //playerObject[i].gameObject.GetComponent<PlayerStat>().calculateExp(sumExpCanGet / playerObject.Length);
            //DataManager.instance.maxHealthPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().maxHealth;
            //DataManager.instance.currentExpPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().currentExp;
            //DataManager.instance.levelPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().playerLv;
            //DataManager.instance.maxManaPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().maxHealth;
            //               DataManager.instance.attackPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().attack;
            //               DataManager.instance.defensePlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().defense;
            //               DataManager.instance.healthPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().health;
            //               DataManager.instance.magicPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().magic;
            //               DataManager.instance.manaPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().mana;
            //               DataManager.instance.speedPlayer1 = playerObject[i].gameObject.GetComponent<PlayerStat>().speed;
            //           }
            //           else if(playerObject[i].gameObject.name == "Player2") {
            //playerObject[i].gameObject.GetComponent<PlayerStat>().calculateExp(sumExpCanGet / playerObject.Length);
            //DataManager.instance.maxHealthPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().maxHealth;
            //DataManager.instance.currentExpPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().currentExp;
            //DataManager.instance.levelPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().playerLv;
            //DataManager.instance.maxManaPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().maxMana;
            //        DataManager.instance.attackPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().attack;
            //        DataManager.instance.defensePlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().defense;
            //        DataManager.instance.healthPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().health;
            //        DataManager.instance.magicPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().magic;
            //        DataManager.instance.manaPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().mana;
            //        DataManager.instance.speedPlayer2 = playerObject[i].gameObject.GetComponent<PlayerStat>().speed;
            //    }
            //}
            GameManager.instance.LoadMapScene();
        }
        GameObject[] remainPlayerUnit = GameObject.FindGameObjectsWithTag("PlayerUnit");
        if (remainPlayerUnit.Length == 0)
        {
            GameManager.instance.LoadGameMenu();
        }
        Debug.Log(isFirstTurn);
        isFirstTurn = false;
        currentUnit = unitStats[0];
        unitStats.Remove(currentUnit);
        if (currentUnit.GameObject.tag != "DeadUnit")
        {
            //GameObject currentUnit = currentUnitStat.gameObject;
            unitStats.Add(currentUnit);
            //unitStats.Sort();
            if (currentUnit.GameObject.tag == "PlayerUnit")
            {
                //choose enemy
                if (isPlayerSelectEnemy == false)
                {
                    for (int i = 0; i < enemyPositionIndex; i++)
                    {
                        if (isEnemyDead[i] == false)
                        {
                            Instantiate(selector, enemySpawnPositions[i].transform.position,
                                        enemySpawnPositions[i].transform.rotation);
                            break;
                        }
                    }
                }
                //player turn
                if (isPlayerSelectEnemy == true)
                {
                    enemyTurn = false;
                    playerList.Remove(currentUnit);
                    currentUnit.GameObject.GetComponent <GetPlayerAction>().
                    AttackTarget(enemyCombatant[enemySelectedPositionIndex].GameObject,
                                 enemyCombatant[enemySelectedPositionIndex]);
                    isPlayerSelectEnemy = false;
                }
            }
            else
            {
                enemyTurn = true;
                currentUnit.GameObject.GetComponent <EnemyAction>().Action();
            }
        }
        else
        {
            unitStats.Add(currentUnit);
            this.nextTurn();
        }
    }
Beispiel #52
0
 public CombatRemoveCombatantEvent(Combatant combatant)
 {
     Combatant = combatant;
 }
Beispiel #53
0
 public abstract Ability selectAbility(Combatant performer);
Beispiel #54
0
 public Defend(Combatant source, Combatant target, int armor) : base(source, target)
 {
     this.armor = armor;
 }
Beispiel #55
0
        private void RefreshCombatants()
        {
            var player = default(Combatant);
            var party  = default(IReadOnlyList <Combatant>);

            lock (SimulationLocker)
            {
                if (this.InSimulation &&
                    this.SimulationPlayer != null &&
                    this.SimulationParty.Any())
                {
                    player = this.SimulationPlayer;
                    party  = this.SimulationParty;
                }
                else
                {
                    player = FFXIVPlugin.Instance?.GetPlayer();
                    party  = FFXIVPlugin.Instance?.GetPartyList();
                }
            }

            if (player != null)
            {
                this.player = player;
            }

            if (party != null)
            {
                var newList = new List <Combatant>(party);

                if (newList.Count < 1 &&
                    !string.IsNullOrEmpty(this.player?.Name))
                {
                    newList.Add(this.player);
                }

                // パーティリストを入れ替える
                this.partyList.Clear();
                this.partyList.AddRange(newList);

                // 読み仮名リストをメンテナンスする
                var newPhonetics =
                    from x in newList
                    select new PCPhonetic()
                {
                    ID     = x.ID,
                    NameFI = x.NameFI,
                    NameIF = x.NameIF,
                    NameII = x.NameII,
                    Name   = x.Name,
                    JobID  = x.JobID,
                };

                WPFHelper.BeginInvoke(() =>
                {
                    var phonetics = TTSDictionary.Instance.Phonetics;

                    var toAdd = newPhonetics.Where(x => !phonetics.Any(y => y.Name == x.Name));
                    phonetics.AddRange(toAdd);

                    var toRemove = phonetics.Where(x => !newPhonetics.Any(y => y.Name == x.Name)).ToArray();
                    foreach (var item in toRemove)
                    {
                        phonetics.Remove(item);
                    }
                });
            }
        }
Beispiel #56
0
    public override Ability selectAbility(Combatant performer)
    {
        switch (state)
        {
        case "start":
            selectedAbility = null;

            menuTitleText.text = performer.CombatantName;

            menuListLoader.menuListProvider = menuListProvider;
            menuListLoader.menuItemSelector = menuItemSelector;
            menuListLoader.loadMenu();

            state = "waitingForAbility";
            break;


        case "waitingForAbility":
            if (menuItemSelector.selectedString != null)
            {
                selectedAbility = menuItemSelector.selectedString;

                // TODO: The combatants we load need to be based off the ability.
                // Cure defaults to party (but can switch to enemy)
                // ALL isn't for all abilities

                loadMenuWithTargets(enemies, "Enemies");

                state = "waitingForTarget";
            }
            break;

        case "selectAlly":

            // TODO: The combatants we load need to be based off the ability.
            // Cure defaults to party (but can switch to enemy)
            // ALL isn't for all abilities

            loadMenuWithTargets(allies, "Allies");

            state = "waitingForTarget";
            break;

        case "waitingForTarget":
            if (menuItemSelector.selectedString != null)
            {
                string selectedTarget = menuItemSelector.selectedString;

                List <Combatant> selectedTargets = new List <Combatant>();

                switch (selectedTarget)
                {
                case "Ally":
                    state = "selectAlly";
                    break;

                case "ALL Enemies":
                    selectedTargets = enemies.combatants;
                    state           = "start";
                    return(abilityFactory.createAbility(selectedAbility, performer, selectedTargets));

                case "ALL Allies":
                    selectedTargets = allies.combatants;
                    state           = "start";
                    return(abilityFactory.createAbility(selectedAbility, performer, selectedTargets));

                default:
                    selectedTargets.Add(selectedFaction.nameToCombatant[selectedTarget]);
                    state = "start";
                    return(abilityFactory.createAbility(selectedAbility, performer, selectedTargets));
                }
            }
            break;

        default:
            break;
        }
        return(null);
    }
Beispiel #57
0
 public AITurnPlan(Combatant combatant)
 {
     this.combatant = combatant;
 }
Beispiel #58
0
 protected override StatusEffect NewStatusEffect(Combatant target)
 {
     return(new OffBalance(target, duration));
 }
Beispiel #59
0
 public RecoveryIcon(StateOfBattle battle, Combatant receiver)
     : base(battle, receiver)
 {
     Message = RECOVERY;
     Color   = Colors.GREEN;
 }
 public void FristTurn()
 {
     //if (enemyList.Count == 0) {
     //	GameManager.instance.LoadMapScene();
     //}
     //if (playerList.Count == 0) {
     //	GameManager.instance.LoadGameMenu();
     //}
     //Combatant currentUnit = playerList[0];
     //playerList.Remove(currentUnit);
     //if (currentUnit.Dead != true) {
     //	GameObject currentUnitObject = currentUnit.GameObject;
     //	Instantiate(selector, enemySpawnPositions[0].transform.position, enemySpawnPositions[0].transform.rotation);
     //}
     //check is game over
     GameObject[] remainEnemyUnit = GameObject.FindGameObjectsWithTag("Enemy");
     if (remainEnemyUnit.Length == 0)
     {
         GameManager.instance.LoadMapScene();
     }
     GameObject[] remainPlayerUnit = GameObject.FindGameObjectsWithTag("PlayerUnit");
     if (remainPlayerUnit.Length == 0)
     {
         GameManager.instance.LoadGameMenu();
     }
     isFirstTurn = true;
     //check enemy turn
     if (playerList.Count == 0)
     {
         //go to next turn
         if (playerList.Count == 0 && enemyList.Count == 0)
         {
             for (int i = 0; i < 2; i++)
             {
                 unitStats.Add(playerCombatant[i]);
             }
             for (int i = 0; i < enemyPositionIndex; i++)
             {
                 unitStats.Add(enemyCombatant[i]);
             }
             unitStats.Sort(delegate(Combatant x, Combatant y) {
                 return(y.Status[9].GetValue().CompareTo(x.Status[9].GetValue()));
             });
             //create queue for next turn
             unitLists = new Queue <Combatant>(unitStats);
             this.nextTurn();
         }
         //enemy turn
         else
         {
             currentUnit = enemyList[0];
             enemyList.Remove(currentUnit);
             enemyTurn = true;
             currentUnit.GameObject.GetComponent <EnemyAction>().Action();
         }
     }
     else
     {
         currentUnit = playerList[0];
         //choose enemy
         if (isPlayerSelectEnemy == false)
         {
             for (int i = 0; i < enemyPositionIndex; i++)
             {
                 if (isEnemyDead[enemyPositionIndex] == false)
                 {
                     Instantiate(selector, enemySpawnPositions[i].transform.position, enemySpawnPositions[i].transform.rotation);
                     break;
                 }
             }
         }
         //player turn
         if (isPlayerSelectEnemy == true)
         {
             enemyTurn = false;
             playerList.Remove(currentUnit);
             currentUnit.GameObject.GetComponent <GetPlayerAction>().
             AttackTarget(enemyCombatant[enemySelectedPositionIndex].GameObject,
                          enemyCombatant[enemySelectedPositionIndex]);
             isPlayerSelectEnemy = false;
         }
     }
 }