Exemple #1
0
    private async Task TypeBashResultAsync(BattleAction battleAction)
    {
        switch (battleAction.Result)
        {
        case BattleActionResult.Smash:
            await AutoTypeAsync($"\nSMAAAASH!!!!");

            goto case BattleActionResult.Successful;

        case BattleActionResult.Successful:
            await AutoTypeAsync($"\n+ {battleAction.Magnitude}HP damage to {battleAction.Target.Name}!");

            return;

        case BattleActionResult.Dodged:
            await AutoTypeAsync($"\n+ {battleAction.Target.Name} dodged!");

            return;

        case BattleActionResult.Failed:
            await AutoTypeAsync($"\n+ {battleAction.Performer.Name} missed!");

            return;

        default:
            throw new InvalidEnumArgumentException("BattleActionResult does not account for given BattleActionResult");
        }
    }
Exemple #2
0
        /// <summary>
        /// Called by the client to attempt to perform an action using the provided BattleAction template.
        /// </summary>
        /// <param name="action">A basic data object containing the parameters to perform an action in battle.</param>
        /// <returns></returns>
        public async Task PerformAction(BattleAction action)
        {
            var userId = Guid.Parse(Context.UserIdentifier);

            action.OwnerId = userId;

            var manager = _playerEntityManagerStore.GetPlayerEntityManager(userId);

            manager.SetDateAccessed();

            var battleManager = manager.GetBattleManager();

            if (battleManager != null)
            {
                var result = await battleManager.PerformActionAsync(action);

                var response = new
                {
                    Action       = action,
                    ErrorMessage = result.FailureReason
                };

                if (!result.IsSuccess)
                {
                    await Clients.Caller.SendAsync("invalidAction", response);
                }
            }
        }
 private void partyMenu_OnSubmit(object sender, EventArgs e)
 {
     selectedAction  = new BattleAction(BattleActionType.ChangeMon, player.Party[partyMenu.SelectedIndex]);
     selectedMonster = player.Party[partyMenu.SelectedIndex];
     battleMenu.ResetSelected();
     syncronize.Set();
 }
Exemple #4
0
    public async Task TypeBattleActionAttemptAsync(BattleAction battleAction)
    {
        textBox.text = string.Empty;
        var attemptedPhrase = attemptedPhrases[Random.Range(0, attemptedPhrases.Length)];

        await AutoTypeAsync($"+ {battleAction.Performer.Name} {attemptedPhrase} to {battleAction.ActionName} {battleAction.Target.Name}.");
    }
Exemple #5
0
    public void AddAction(EAction action, Character chara)
    {
        BattleAction newAction  = null;
        Character    playerPeek = m_PlayerCharacters.Peek();
        Character    enemyPeek  = m_EnnemyCharacters.Peek();

        switch (action)
        {
        case EAction.Attack:
            newAction = new Attack(chara.GetStrength(), chara, m_IsPlayerTurn ? enemyPeek : playerPeek);
            break;

        case EAction.Defense:
            newAction = new Defense(chara.GetMagic(), chara, chara);
            break;

        case EAction.Heal:
            newAction = new Heal(chara.GetMagic(), chara, m_IsPlayerTurn ? playerPeek : enemyPeek);
            break;

        case EAction.Protect:
            newAction = new Protect(chara, m_IsPlayerTurn ? playerPeek : enemyPeek);
            break;

        case EAction.Bound:
            newAction = new Bound(chara, m_IsPlayerTurn ? playerPeek : enemyPeek);
            break;
        }

        m_Actions.Enqueue(newAction);
    }
 private void moveMenu_OnSubmit(object sender, EventArgs e)
 {
     moveDisplay.Hide();
     selectedAction           = new BattleAction(BattleActionType.UseMove);
     selectedAction.WhichMove = moveMenu.SelectedIndex;
     syncronize.Set();
 }
Exemple #7
0
 public override void Reaction(BattleAction act)
 {
     if (act.Tags.Contains("dmg"))
     {
         HP--;
     }
 }
Exemple #8
0
        override public void execute(BattleAction action, BattleContext context)
        {
            var attack = (BattleUnitAttackAction)action;
            var from   = context.actors.getActorByObjectId(attack.fromObjectId) as BattleBuilding;
            var to     = context.actors.getActorByObjectId(attack.toObjectId) as BattleBuilding;

            var regen     = from.GetComponent <UnitRegenComponent>();
            var unitCount = regen.removeHalf();

            if (unitCount > 0)
            {
                var unit = context.actors.factory.unitFactory.instantiate <BattleUnit>();
                context.actors.units.AddComponent(unit);

                unit.initialize(from, to, unitCount);

                var createUnit = context.output.enqueueByFactory <UnitCreateEvent>();
                createUnit.objectId   = unit.objectId;
                createUnit.unitId     = unit.unitId;
                createUnit.level      = unit.level;
                createUnit.ownerId    = unit.ownerId;
                createUnit.units      = unit.units.count;
                createUnit.x          = unit.transform.x;
                createUnit.y          = unit.transform.y;
                createUnit.toObjectId = to.objectId;

                var evt = context.output.enqueueByFactory <UnitAttackEvent>();
                evt.count     = unitCount;
                evt.unitId    = unit.unitId;
                evt.unitLevel = unit.level;
                evt.from      = attack.fromObjectId;
                evt.to        = attack.toObjectId;
                evt.tick      = action.tick;
            }
        }
    private List <IBattleActionListener> getListeners(BattleAction action, BattleActionContext battleActionContext, MoveContext moveContext)
    {
        List <IBattleActionListener> listeners = new List <IBattleActionListener>();

        //TODO fix watcher to be more flexible

        List <IBattleActionListener> relevantList = null;

        if (action is DamageBattleAction)
        {
            relevantList = damageListeners;
        }
        if (action is StatusBattleAction)
        {
            relevantList = statusListeners;
        }

        if (relevantList != null)
        {
            foreach (IBattleActionListener listener in relevantList)
            {
                if (listener.isListeningFor(action))
                {
                    listeners.Add(listener);
                }
            }
        }
        return(listeners);
    }
Exemple #10
0
    /// <summary>
    /// Function called to process the given action with the given targets by
    /// the given user.
    /// </summary>
    /// <param name="processingAction"> The given action being processed
    ///   </param>
    /// <param name="givenTargets"> The list of lists of targets; each list
    ///   is for a single action's targets; there will be more than one list if
    ///   there are follow up actions; each list correlates to an action in the
    ///   queue of follow up actions i.e. the first list will go to the first
    ///   action, the second list will go to the second action until there are
    ///   no more actions.</param>
    /// <param name="user">The user of the action Hopefully we will create a
    ///   a parent class to house hunter and monster scripts but for now this
    ///   function only accepts hunter battle puppet scripts.</param>
    public void processAction(BattleAction processingAction,
                              List <List <System.Object> > givenTargets,
                              ParentPuppetScript user)
    {
        user.setCurrentActionPointCount(user.getCurrentActionPointCount()
                                        - ((BattleAction)processingAction).apCost);

        // Based on the type of action being processed, relay the given
        //   parameters to a function to handle that specific type of action.
        switch (processingAction)
        {
        case MeleeAction meleeAction:
            processMeleeAction(meleeAction, givenTargets[0],
                               user);
            break;
        }


        // If the processing action is a followup then there must be a 2nd list;
        //   recursively call this function with the followup action and
        //   the list of list of targets with the front most list popped out.
        if (processingAction is FollowupAction)
        {
            givenTargets.Remove(givenTargets[0]);

            processAction(((FollowupAction)processingAction).getFollowup(),
                          givenTargets, user);
        }
    }
 public void SelectAction(BattleAction _attack)
 {
     selectedAction = _attack;
     SetupTargets();
     PSS = PlayerSelectionStage.SelectTarget;
     DestroyMenu();
 }
Exemple #12
0
 private void HandleOnActionComplete(Pawn pawn, BattleAction action)
 {
     if (gameObject.activeSelf)
     {
         Refresh();
     }
 }
Exemple #13
0
 public int Damage(BattleAction action)
 {
     int id = this.GetBattleID();
     if(this.combatant != null &&
         (!this.combatant.isDead || action.reviveFlag))
     {
         CombatantAnimation[] anims = action.Calculate(
                 new Combatant[] {this.combatant}, this.damageFactor);
         if(anims.Length > 0)
         {
             string name = this.combatant.GetAnimationName(anims[0]);
             if(name != "" && this.combatant.prefabInstance != null &&
                 this.combatant.prefabInstance.animation != null &&
                 this.combatant.prefabInstance.animation[name] &&
                 (DataHolder.BattleSystem().playDamageAnim ||
                 !this.combatant.IsInAction() ||
                 !(DataHolder.BattleSystem().dynamicCombat ||
                 DataHolder.BattleSystem().IsRealTime())))
             {
                 this.combatant.prefabInstance.animation.CrossFade(name, 0.3f, PlayMode.StopSameLayer);
             }
         }
     }
     return id;
 }
Exemple #14
0
        private static AttackGymResponse LeaveBattle(FortData gym, Client client, StartGymBattleResponse resp, AttackGymResponse attResp, BattleAction lastRetrievedAction)
        {
            var timeMs = attResp.BattleLog.ServerMs;
            var attack = new BattleAction();

            attack.Type = BattleActionType.ActionPlayerQuit;

            attack.TargetIndex = -1;
            if (attResp.ActiveAttacker != null)
            {
                attack.ActivePokemonId = attResp.ActiveAttacker.PokemonData.Id;
            }
            var battleActions = new List <BattleAction>();

            battleActions.Add(attack);
            lastRetrievedAction = new BattleAction();
            AttackGymResponse ret;
            var times = 3;

            do
            {
                ret = client.Fort.AttackGym(gym.Id, resp.BattleId, battleActions, lastRetrievedAction);
                times--;
            } while (ret.Result != AttackGymResponse.Types.Result.Success && times > 0);

            return(ret);
        }
    // Update is called once per frame
    private void Update()
    {
        switch (battleState)
        {
        case PerformAction.Waiting:
            if (actions.Count > 0)
            {
                battleState = PerformAction.PrepareAction;
            }
            break;

        case PerformAction.PrepareAction:
            BattleAction action = actions[0];

            GameObject performer = action.attackerGameObject;
            if (action.attackerType == BattleAction.ToonType.Enemy)
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();
                esm.heroToAttack = action.defenderGameObject;
                esm.currentState = EnemyStateMachine.TurnState.PerformAction;
            }
            else     // if hero
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                hsm.enemyToAttack = action.defenderGameObject;
                hsm.currentState  = HeroStateMachine.TurnState.PerformAction;
            }

            battleState = PerformAction.PerformAction;
            break;

        case PerformAction.PerformAction:
            // idle
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        switch (HeroInput)
        {
        case HeroGui.Activate:
            if (heroesToManage.Count > 0)
            {
                // heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroesToManage[0].GetComponent <HeroStateMachine>().Selector.SetActive(true);

                AttackPanel.SetActive(true);
                HeroInput = HeroGui.Waiting;
            }
            break;

        case HeroGui.Waiting:
            // idle;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Exemple #16
0
        public ActionCommand(float startTime, float endTime, BattleAction action, FieldObject owner)
        {
            this.StartTime = startTime;
            this.EndTime   = endTime;

            ActionBehaviour = BattleActionBehaviourFactory.Create(action, owner);
        }
 public BattleEvent(Character currentActor, BattleAction actorAction, Character actorTarget)
 {
     mActor = currentActor;
     mAction = actorAction;
     actionOutcome = mAction.ToString();
     mActee = actorTarget;
 }
Exemple #18
0
    public void React(BattleAction ba)
    {
        bool ok = false;

        foreach (var t in ba.Tags)
        {
            if (ok)
            {
                break;
            }
            foreach (var t2 in Tags)
            {
                if (t2 == t)
                {
                    ok = true;
                    break;
                }
            }
        }

        if (ok)
        {
            foreach (var ev in Events)
            {
                ev.Activate(ba.battle);
            }
        }
        else
        {
            Next.React(ba);
        }
    }
Exemple #19
0
 public void continueBattle(BattleAction battleAction)
 {
     if (battleAction != null) {
         battleTurns[battleTurns.Count - 1].addBattleAction(battleAction);
     }
     BattleCharacter nextNotActionedCharacter = battleTurns[battleTurns.Count - 1].getNextNotActionedCharacter();
     if (nextNotActionedCharacter == null) {
         //no next character
         //means all characters already choose actions, start this turn
         battleTurns[battleTurns.Count - 1].start();
         //judge the result of this battle
         if (this.isWin()) {
             this.result = BattleConstants.RESULT_WIN;
             battleManager.log(result);
         } else if (this.isLose()) {
             this.result = BattleConstants.RESULT_LOSE;
             battleManager.log(result);
         }
         //Enter next turn
         BattleTurn battleTurn = new BattleTurn(battleManager, battleCharacters);
         battleTurns.Add(battleTurn);
         battleManager.log("Turn: " + battleTurns.Count + "\n\n");
         //get new next character
         nextNotActionedCharacter = battleTurns[battleTurns.Count - 1].getNextNotActionedCharacter();
     }
     battleManager.updateBattleActionOptions(nextNotActionedCharacter);
 }
Exemple #20
0
 private void HandleOnActionComplete(Pawn pawn, BattleAction action)
 {
     if (pawn == this && !CanAct())
     {
         TurnManager.Instance.RequestTurnEnd();
     }
 }
        /// <summary>
        ///     Creates the the buttons for all actions
        /// </summary>
        public void CreateActionButtons()
        {
            this.DestroyActionButtons();

            this.actionButtons      = new Button[this.Actions.Length];
            this.actionButtonHolder = MonoBehaviour.Instantiate(GenericPrefab.Panel, HudManager.BattleHud.transform);

            for (int i = 0; i < this.Actions.Length; i++)
            {
                int          actionIndex = i;
                BattleAction action      = this.Actions[actionIndex];

                Button actionButton = MonoBehaviour.Instantiate(GenericPrefab.Button, this.actionButtonHolder.transform);
                actionButton.SetText(string.Format("{0} [{1} AP]", action.Name, action.AttackPointCost));

                actionButton.SetAnchoredPosition3D(
                    new Vector3(0.0f, (this.Actions.Length - actionIndex) * PlayerTurn.ButtonHeight, 0.0f),
                    PlayerTurn.ButtonAnchorPoint);

                // Action Selection
                actionButton.onClick.AddListener(delegate
                {
                    this.CreateTargetButtons(action);

                    for (int j = 0; j < this.actionButtons.Length; j++)
                    {
                        this.actionButtons[j].interactable = j != actionIndex;
                    }
                });

                this.actionButtons[actionIndex] = actionButton;
            }
        }
Exemple #22
0
 public FocusPoint(FocusTrigger focusTrigger, BattleAction battleAction, List <Pair <StatName, StatModifier> > statModifiers, string description)
 {
     this.focusTrigger  = focusTrigger;
     this.battleAction  = battleAction;
     this.statModifiers = statModifiers;
     this.description   = description;
 }
Exemple #23
0
    //Clearing prepared battle action
    public void ClearBattleAction()
    {
        if (battleAction == null){ return;}

        battleAction.actionTargetUnit.setIsTargeted(false);
        battleAction = null;
    }
Exemple #24
0
    /// <summary>
    /// Selects an action by index that will be performed by the actor.
    /// </summary>
    public void SelectActionByIndex(int index)
    {
        // Get action name from actor
        BattleAction action = SelectedActor.Actions[index];

        SelectAction(action);
    }
Exemple #25
0
        protected override void Execute(List <ClientEntity> entities)
        {
            foreach (var e in entities)
            {
                BattleAction     action = e.battleAction.value;
                BattleActionType type   = action.type;
                int          id         = action.subject;
                ClientEntity subject    = _context.GetEntityWithBattleUnitId(id);

                switch (type)
                {
                case BattleActionType.Move:
                    BattleActionMove battleActionMove = action as BattleActionMove;
                    subject.ReplaceSpeed(battleActionMove.speed);
                    subject.ReplaceDirection(battleActionMove.dir);
                    break;

                case BattleActionType.Stop:
                    BattleActionStop battleActionStop = action as BattleActionStop;
                    subject.ReplaceSpeed(0);
                    subject.ReplacePosition(battleActionStop.position);
                    break;

                default:
                    break;
                }
            }
        }
Exemple #26
0
    public void ChooseAction(List <Character> possible_targets)
    {
        SetPossibleAction();

        int random_number = UnityEngine.Random.Range(0, 100);

        if (random_number <= attack_frequency)
        {
            selected_action = possible_actions[0];
        }
        else
        {
            selected_action = possible_actions[UnityEngine.Random.Range(1, possible_actions.Count)];
        }

        if (selected_action is JohnSpecial)
        {
            ChooseFriendlyTarget(possible_targets);
        }
        else
        {
            ChooseTarget(possible_targets);
        }
        //ChooseObject();
    }
 public static int CompareActions(BattleAction a, BattleAction b)
 {
     // if a is higher than b, result is negative
     // if b is higher than a, result is positive
     // if equal, result is 0
     return((int)(b.Speed() - a.Speed()));
 }
    public static BattleAction battleActionFromJson(JSONObject j)
    {
        if (j.type != JSONObject.Type.OBJECT)
        {
            throw new System.Exception("There was an error parsing single BattleAction");
        }

        int          id;
        string       name;
        BattleAction result = null;

        j.GetField(out id, "actionId", -1);
        j.GetField(out name, "name", "");
        switch ((BATTLE_ACTION_MAPPING)id)
        {
        case BATTLE_ACTION_MAPPING.DAMAGE:
            result = DamageBattleAction.fromJSONObject(j);
            break;

        case BATTLE_ACTION_MAPPING.STATUS:
            result = StatusBattleAction.fromJSONObject(j);
            break;

        case BATTLE_ACTION_MAPPING.BUFF:
            result = BuffBattleAction.fromJSONObject(j);
            break;

        case BATTLE_ACTION_MAPPING.COMPOSITE:
            result = BattleActionsSharingContext.fromJSONObject(j);
            break;
        }

        return(result);
    }
Exemple #29
0
    /// <summary>
    /// Selects an action by name to be used by the current actor.
    /// </summary>
    public void SelectActionByName(string name)
    {
        // Create an instance of the action
        BattleAction action = SelectedActor.Actions[name];

        SelectAction(action);
    }
    void QueueAction()
    {
        BattleAction theAction = _actions[_actionSelection];

        theAction.source = this;
        _manager.AddAction(theAction);
    }
Exemple #31
0
    private bool resetProcessingAction()
    {
        if (processingAction == null)
        {
            return(false);
        }

        processingAction = null;

        originalAction = null;

        selectedMonster = null;

        previousTargetsCount = 0;

        currentTargetIndex = 0;

        actionTargetIndex = 0;

        foreach (List <System.Object> list in targets)
        {
            list.Clear();
        }

        targets.Clear();

        return(true);
    }
    public void Enter(BattleAction action, TargetData targetData)
    {
        BattleMoveTemplate template = templateInstancePool.Dequeue();

        template.UpdateMoveText(action.MenuText);
        template.UpdateOriginText(targetData.origin.CharacterClass.ClassName + " used");
        StartCoroutine(AddActiveTemplate(template));
    }
Exemple #33
0
        public static BattleAction Battle_ChooseAction(ActiveMonster current, Trainer trainer, bool canAttack)
        {
            BattleAction ret = new BattleAction();

            ret.Type      = BattleActionType.UseMove;
            ret.WhichMove = Rng.Next(0, current.Moves.Count(m => m != null));
            return(ret);
        }
Exemple #34
0
 private void DisplayActionTargetRestrictions(BattleAction action)
 {
     foreach (IBattleActionElement element in action.TargetingRestrictions)
     {
         BattleActionElementDisplay display = BattleActionElementDisplayManager.Instance.GetDisplay(element);
         targetRestictionLayout.Add(display.transform);
     }
 }
Exemple #35
0
 public void SetAction(BattleAction a)
 {
     this.action = a;
     if(this.action != null && this.action.user != null &&
         this.combatant == null)
     {
         this.combatant = this.action.user;
     }
 }
Exemple #36
0
 public void executeAction(BattleAction actionToExecute)
 {
     actionToExecute.specificAction(currentActor, turnOrder);
     ArrayList executedActions = actionToExecute.getBattleEvents();
     foreach (BattleEvent currentEvent in executedActions)
     {
         mGame.giveBattleOutput(currentEvent);
     }
     selectNextCharacter();
 }
Exemple #37
0
        public async Task<AttackGymResponse> AttackGym(string fortId, string battleId, List<BattleAction> battleActions, BattleAction lastRetrievedAction)
        {
            var message = new AttackGymMessage()
            {
                BattleId = battleId,
                GymId = fortId,
                LastRetrievedActions = lastRetrievedAction,
                PlayerLatitude = _client.CurrentLatitude,
                PlayerLongitude = _client.CurrentLongitude,
                AttackActions = { battleActions }
            };

            message.AttackActions.AddRange(battleActions);

            return await _baseRpc.PostProtoPayload<Request, AttackGymResponse>(RequestType.AttackGym, message);
        }
        public BattleEvent(Character currentActor, BattleAction actorAction, Character actorTarget)
        {
            mActor = currentActor;
            mAction = actorAction;
            actionOutcome = mAction.toString();
            mActee = actorTarget;

            if (mActee.isDead && !mActee.isPlayer)
            {
                ((PlayerCharacter)mActor).gainExperience(((Enemy)mActee).Worth);
                kill_string = ", " + mActee.Name + " was vanquished!";
            }

            if (mActee.isDead && mActee.isPlayer)
            {
                kill_string = ", " + mActee.Name + " has been slain!";
            }
        }
Exemple #39
0
        public void chooseBattleActionOptions()
        {
            List<BattleSkill> skills = this.focusedBattleCharacter.getSkills();
            skills.Sort();
            battleCharacters.Sort();

            BattleAction battleAction = new BattleAction();
            battleAction.sources.Add(this.focusedBattleCharacter);
            battleAction.skill = skills[skillsDropdown.value];

            //get the target character
            int targetCharacterIndex = -1;
            for (int i = 0; i < battleCharacters.Count; i++) {
                if (battleCharacters[i].role == BattleConstants.CHARACTER_ROLE_BLUE) {
                    targetCharacterIndex++;
                    if (targetCharacterIndex == bluesDropdown.value) {
                        battleAction.targets.Add(battleCharacters[i]);
                    }
                }
            }

            this.battle.continueBattle(battleAction);
            return;
        }
Exemple #40
0
    /*
    ============================================================================
    Use functions
    ============================================================================
    */
    public CombatantAnimation[] Use(Combatant user, Combatant[] target, BattleAction ba, int id, float damageFactor, float damageMultiplier)
    {
        AudioClip clip = null;
        if(this.audioName != "")
        {
            clip = (AudioClip)Resources.Load(ItemData.AUDIO_PATH+this.audioName, typeof(AudioClip));
        }

        CombatantAnimation[] anims = new CombatantAnimation[target.Length];
        // global event
        if(this.callGlobalEvent)
        {
            GameHandler.GetLevelHandler().CallGlobalEvent(this.globalEventID);
        }
        // use item
        else
        {
            for(int j=0; j<target.Length; j++)
            {
                if(clip != null && target[j].prefabInstance != null)
                {
                    AudioSource s = target[j].prefabInstance.GetComponentInChildren<AudioSource>();
                    if(s == null) s = target[j].prefabInstance.AddComponent<AudioSource>();
                    if(s != null)
                    {
                        s.PlayOneShot(clip);
                    }
                }

                anims[j] = CombatantAnimation.NONE;
                for(int i=0; i<this.valueChange.Length; i++)
                {
                    if(!target[j].isDead || (target[j].isDead && this.revive && !target[j].noRevive))
                    {
                        if(this.revive && target[j].isDead && !target[j].noRevive)
                        {
                            target[j].isDead = false;
                            anims[j] = CombatantAnimation.REVIVE;
                        }
                        if(this.valueChange[i].active)
                        {
                            int oldVal = target[j].status[i].GetValue();
                            int change = this.valueChange[i].ChangeValue(i, -1, user, target[j], true, damageFactor, damageMultiplier);
                            if(!(this.revive && target[j].isDead && !target[j].noRevive) && ((this.valueChange[i].IsSub() && change > 0) ||
                                (this.valueChange[i].IsAdd() && change < 0) ||
                                (this.valueChange[i].IsSet() && change < oldVal)))
                            {
                                anims[j] = CombatantAnimation.DAMAGE;
                            }
                        }
                    }
                }
            }
            if(ItemSkillType.USE.Equals(this.itemSkill))
            {
                anims = DataHolder.Skill(this.skillID).Use(user, target, ba, false, this.skillLevel-1, damageFactor, damageMultiplier);
            }
            else if(ItemSkillType.LEARN.Equals(this.itemSkill))
            {
                for(int j=0; j<target.Length; j++)
                {
                    if(target[j] is Character)
                    {
                        Character t = (Character)target[j];
                        t.LearnSkill(this.skillID, this.skillLevel);
                    }
                }
            }
            if(ItemVariableType.SET.Equals(this.itemVariable))
            {
                GameHandler.SetVariable(this.variableKey, this.variableValue);
            }
            else if(ItemVariableType.REMOVE.Equals(this.itemVariable))
            {
                GameHandler.RemoveVariable(this.variableKey);
            }
            for(int j=0; j<target.Length; j++)
            {
                this.ApplyEffects(user, target[j]);
            }
        }
        // consume
        if(user is Character)
        {
            DataHolder.Statistic.ItemUsed(id);
            if(this.learnRecipe) GameHandler.LearnRecipe(this.recipeID);
            if(this.consume) GameHandler.RemoveItem(id);
        }
        return anims;
    }
Exemple #41
0
 public Event(Character currentActor, BattleAction actorAction, Character actorTarget)
 {
     mActor = currentActor;
     mAction = actorAction;
     mActee = actorTarget;
 }
Exemple #42
0
 public BattleMenuItem(GUIContent c, int i, int ul, string t, bool it, string inf, BattleAction a)
 {
     this.content = c;
     this.id = i;
     this.useLevel = ul;
     this.type = t;
     this.isTarget = it;
     this.info = inf;
     this.action = a;
     if(this.action != null)
     {
         this.action.CheckRevive();
     }
 }
 //Actions storage
 private void AddAction(BattleAction newAction)
 {
     actions.Add(newAction);
 }
Exemple #44
0
 public BattlePhaseAction(BattleAction action, int[] indexes)
 {
     Action = action;
     Index = indexes[(int)action];
 }
Exemple #45
0
 public static BattleAction[] Remove(int index, BattleAction[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(BattleAction str in list) tmp.Add(str);
     tmp.RemoveAt(index);
     return tmp.ToArray(typeof(BattleAction)) as BattleAction[];
 }
 public void Init(BattleMenuItem bmi)
 {
     this.bmTitle = this.owner.GetName();
     this.blinkSet = -1;
     if(BattleMenuMode.BASE.Equals(this.mode))
     {
         this.bmPosition = DataHolder.BattleMenu().dialoguePosition;
         this.list = DataHolder.BattleMenu().BattleMenuList(this.owner);
     }
     else if(BattleMenuMode.SKILL.Equals(this.mode))
     {
         this.bmPosition = DataHolder.BattleMenu().skillPosition;
         this.list = DataHolder.BattleMenu().GetSkillMenuList(-1, this.owner);
     }
     else if(BattleMenuMode.ITEM.Equals(this.mode))
     {
         this.bmPosition = DataHolder.BattleMenu().itemPosition;
         this.list = DataHolder.BattleMenu().GetItemMenuList(-1, this.owner);
     }
     else if(BattleMenuMode.TARGET.Equals(this.mode))
     {
         this.bmPosition = DataHolder.BattleMenu().targetPosition;
         if(BattleMenu.SKILL == bmi.type &&
             DataHolder.Skill(bmi.id).targetRaycast.NeedInteraction())
         {
             this.rayTarget = true;
             this.rayAction = new BattleAction(AttackSelection.SKILL, this.owner,
                         BattleAction.NONE, bmi.id, bmi.useLevel);
             this.rayAction.targetRaycast = DataHolder.Skill(bmi.id).targetRaycast;
             this.list = new BattleMenuItem[0];
             this.hide = true;
         }
         else if(BattleMenu.ITEM == bmi.type &&
             DataHolder.Item(bmi.id).targetRaycast.NeedInteraction())
         {
             this.rayTarget = true;
             this.rayAction = new BattleAction(AttackSelection.ITEM, this.owner,
                         BattleAction.NONE, bmi.id, bmi.useLevel);
             this.rayAction.targetRaycast = DataHolder.Item(bmi.id).targetRaycast;
             this.list = new BattleMenuItem[0];
             this.hide = true;
         }
         else this.list = DataHolder.BattleMenu().GetTargetMenuList(bmi, this.owner);
     }
     this.UpdateChoices(true);
 }
 public void MoveCurrentCharacter(MapPosition targetPosition)
 {
     if (this.CurrentActor != null && this._currentMovablePositions != null)
     {
         if (this._currentMovablePositions.Contains(targetPosition))
         {
             var action = new BattleAction(this.CurrentActor, Const.ActionType.Movement, Const.TargetType.Tile, targetPosition, null);
             var actionQueue = new Queue<BattleAction>();
             actionQueue.Enqueue(action);
             var resultQueue = ServiceFactory.GetBattleService().GetActionResults(actionQueue, this._mapTiles, this._battleCharacters);
             this.ProcessActionResult(resultQueue, BattlePhase.ActionSelect);
         }
     }
 }
    private void PreCalculateActionResults(MapPosition targetPosition)
    {
        if(this.CurrentActor != null && this.CurrentActor.SelectedSkill != null)
        {
            var selectedSkill = this.CurrentActor.SelectedSkill;

            var action = new BattleAction(this.CurrentActor, Const.ActionType.Skill, Const.TargetType.Tile, targetPosition, selectedSkill);
            var actionQueue = new Queue<BattleAction>();
            actionQueue.Enqueue(action);

            this._currentActionResults = ServiceFactory.GetBattleService().GetActionResults(actionQueue, this._mapTiles, this._battleCharacters);
            this.turnOrderModel.UpdateTurnOrder(this.AllBattleCharacters, this._currentActionResults);

            var isValidResult = false;
            foreach (var result in this._currentActionResults)
            {
                if (result.HasResult)
                {
                    isValidResult = true;
                    break;
                }
            }

            if (isValidResult)
            {
                this.SetCharacterSelectedSkillTarget(this.CurrentActor, targetPosition);
            }
            else
            {
                this.UnsetCharacterSelectedSkillTarget(this.CurrentActor);
            }
        }
    }
Exemple #49
0
    public CombatantAnimation[] Use(Combatant user, Combatant[] target, BattleAction ba, 
			bool uc, int lvl, float damageFactor, float damageMultiplier)
    {
        return this.level[lvl].Use(user, target, ba, uc, this.realID, damageFactor, damageMultiplier);
    }
Exemple #50
0
    public override bool UseBaseAttack(Combatant target, BattleAction ba, 
			bool counter, float damageFactor, float damageMultiplier)
    {
        bool hit = false;
        bool found = false;
        for(int i=0; i<this.equipment.Length; i++)
        {
            if(this.equipment[i].IsWeapon())
            {
                Weapon wpn = DataHolder.Weapon(this.equipment[i].equipID);
                if(wpn.ownAttack)
                {
                    if(wpn.UseBaseAttack(this, target, damageFactor, damageMultiplier))
                    {
                        hit = true;
                    }
                    found = true;
                }
            }
        }

        if(!found)
        {
            hit = DataHolder.BaseAttack(this.baseAttack[this.baIndex]).Use(this, this.baseElement, target, damageFactor, damageMultiplier);
        }

        if(!this.isDead && counter && this.battleID != target.battleID)
        {
            if(DataHolder.BattleSystem().IsRealTime()) target.UseCounter(this);
            else if(ba != null) ba.doCounter = new bool[] {target.UseCounter(this)};
        }

        return hit;
    }
Exemple #51
0
        public void updateBattleActionOptions(BattleCharacter battleCharacter)
        {
            this.focusedBattleCharacter = battleCharacter;

            if (focusedBattleCharacter.role == BattleConstants.CHARACTER_ROLE_BLUE) {
                BattleAction battleAction = new BattleAction();
                battleAction.sources.Add(focusedBattleCharacter);
                battleAction.skill = focusedBattleCharacter.getSkills()[0];

                int targetCharacterIndex = 0;
                for (int i = 0; i < battleCharacters.Count; i++) {
                    if (battleCharacters[i].role == BattleConstants.CHARACTER_ROLE_RED) {
                        targetCharacterIndex = i;
                        break;
                    }
                }
                battleAction.targets.Add(battleCharacters[targetCharacterIndex]);

                this.battle.continueBattle(battleAction);
                return;
            }

            List<BattleSkill> skills = this.focusedBattleCharacter.getSkills();
            skills.Sort();
            battleCharacters.Sort();

            redsDropdown.options.Clear();
            Dropdown.OptionData redCharactersOptionData = new Dropdown.OptionData();
            redCharactersOptionData.text = battleCharacter.name;
            redsDropdown.options.Add(redCharactersOptionData);

            skillsDropdown.options.Clear();
            for (int i = 0; i < skills.Count; i++) {
                Dropdown.OptionData skillOptionData = new Dropdown.OptionData();
                skillOptionData.text = skills[i].name;
                skillsDropdown.options.Add(skillOptionData);
            }

            bluesDropdown.options.Clear();
            for (int i = 0; i < battleCharacters.Count; i++) {
                if (battleCharacters[i].role == BattleConstants.CHARACTER_ROLE_BLUE) {
                    Dropdown.OptionData blueOptionData = new Dropdown.OptionData();
                    blueOptionData.text = battleCharacters[i].name;
                    bluesDropdown.options.Add(blueOptionData);
                }
            }
        }
 /*
 ============================================================================
 Interaction functions
 ============================================================================
 */
 public void Select(int index)
 {
     BattleMenuItem prevItem = this.lastBMItem;
     this.lastBMItem = this.list[this.realID[index]];
     if(this.lastBMItem.isTarget)
     {
         if((this.lastBMItem.type == BattleMenu.ATTACK && this.owner.IsBlockAttack()) ||
                 (this.lastBMItem.type == BattleMenu.SKILL && this.owner.IsBlockSkills()) ||
                 (this.lastBMItem.type == BattleMenu.ITEM && this.owner.IsBlockItems()))
         {
             this.lastBMItem = null;
         }
         else if(this.lastBMItem.action == null)
         {
             if(this.lastBMItem.type == BattleMenu.SKILL &&
                 !DataHolder.Skill(this.lastBMItem.id).CanUse(this.owner, this.lastBMItem.useLevel))
             {
                 this.mode = BattleMenuMode.SKILL;
                 this.list = DataHolder.BattleMenu().GetSkillMenuList(DataHolder.Skill(this.lastBMItem.id).skilltype, this.owner);
                 this.bmPosition = DataHolder.BattleMenu().skillPosition;
                 this.UpdateChoices(true);
                 this.lastBMItem = new BattleMenuItem(new GUIContent(""), -1, BattleMenu.SKILL, false, "");
             }
             else
             {
                 BattleMenuItem[] newList = DataHolder.BattleMenu().GetTargetMenuList(this.lastBMItem, this.owner);
                 if((DataHolder.BattleMenu().addBack && newList.Length > 1) ||
                     (!DataHolder.BattleMenu().addBack && newList.Length > 0))
                 {
                     this.mode = BattleMenuMode.TARGET;
                     this.list = newList;
                     this.bmPosition = DataHolder.BattleMenu().targetPosition;
                     this.UpdateChoices(true);
                 }
                 else
                 {
                     this.lastBMItem = prevItem;
                     GameHandler.GetLevelHandler().SetLastBMIndex();
                 }
             }
         }
         else
         {
             BattleAction action = this.lastBMItem.action;
             action.BlinkTargets(false);
             if(action.targetRaycast.NeedInteraction())
             {
                 this.rayTarget = true;
                 this.rayAction = action;
                 this.mode = BattleMenuMode.TARGET;
                 this.list = new BattleMenuItem[0];
                 this.UpdateChoices(true);
                 this.hide = true;
             }
             else
             {
                 if(action.targetRaycast.active)
                 {
                     action.rayTargetSet = true;
                     action.rayPoint = action.targetRaycast.GetRayPoint(this.owner.prefabInstance, VectorHelper.GetScreenCenter());
                 }
                 this.owner.EndBattleMenu(false);
                 this.owner.AddAction(action);
             }
         }
     }
     else
     {
         if(this.lastBMItem.type == BattleMenu.SKILL)
         {
             if(this.owner.IsBlockSkills())
             {
                 this.lastBMItem = null;
             }
             else
             {
                 this.mode = BattleMenuMode.SKILL;
                 this.list = DataHolder.BattleMenu().GetSkillMenuList(this.lastBMItem.id, this.owner);
                 this.bmPosition = DataHolder.BattleMenu().skillPosition;
                 this.UpdateChoices(true);
             }
         }
         else if(this.lastBMItem.type == BattleMenu.ITEM)
         {
             if(this.owner.IsBlockItems())
             {
                 this.lastBMItem = null;
             }
             else
             {
                 this.mode = BattleMenuMode.ITEM;
                 this.list = DataHolder.BattleMenu().GetItemMenuList(this.lastBMItem.id, this.owner);
                 this.bmPosition = DataHolder.BattleMenu().itemPosition;
                 this.UpdateChoices(true);
             }
         }
         else if(this.lastBMItem.type == BattleMenu.DEFEND)
         {
             if(this.owner.IsBlockDefend())
             {
                 this.lastBMItem = null;
             }
             else
             {
                 this.owner.EndBattleMenu(false);
                 this.owner.AddAction(new BattleAction(AttackSelection.DEFEND,
                         this.owner, this.owner.battleID, -1, 0));
             }
         }
         else if(this.lastBMItem.type == BattleMenu.ESCAPE)
         {
             if(this.owner.IsBlockEscape() || !DataHolder.BattleSystem().canEscape)
             {
                 this.lastBMItem = null;
             }
             else
             {
                 this.owner.EndBattleMenu(false);
                 this.owner.AddAction(new BattleAction(AttackSelection.ESCAPE,
                         this.owner, this.owner.battleID, -1, 0));
             }
         }
         else if(this.lastBMItem.type == BattleMenu.ENDTURN)
         {
             this.owner.EndTurn();
         }
         else if(this.lastBMItem.type == BattleMenu.BACK)
         {
             this.lastBMItem = prevItem;
             GameHandler.GetLevelHandler().BattleMenuBack(true);
         }
     }
 }
Exemple #53
0
 public static BattleAction[] Add(BattleAction n, BattleAction[] list)
 {
     ArrayList tmp = new ArrayList();
     foreach(BattleAction str in list) tmp.Add(str);
     tmp.Add(n);
     return tmp.ToArray(typeof(BattleAction)) as BattleAction[];
 }
 public void SetRayPoint(Vector3 point)
 {
     if(this.rayTarget && this.rayAction != null)
     {
         this.rayAction.rayTargetSet = true;
         this.rayAction.rayPoint = point;
         this.owner.EndBattleMenu(false);
         this.owner.AddAction(this.rayAction);
         this.rayAction = null;
         this.rayTarget = false;
     }
 }
Exemple #55
0
 public BattlePhaseAction(BattleAction action)
 {
     Action = action;
     Index = 0;
 }
Exemple #56
0
 //Send GameEvent with combatAction method (delegate)
 private void InvokeAction(Unit targetUnit, CombatAction combatAction, Sprite actionIcon)
 {
     battleAction = new BattleAction("Battle Action", combatAction, this, targetUnit, actionIcon);
 }
 public GameEvent(BattleAction action)
 {
     this.action = action;
 }
Exemple #58
0
    /*
    ============================================================================
    Action handling functions
    ============================================================================
    */
    public BattleAction GetAction(Combatant c, int valid, Combatant[] allies, Combatant[] enemies)
    {
        BattleAction action = new BattleAction();
        bool found = false;
        bool targetEnemy = false;
        int difID = GameHandler.GetDifficulty();
        if(this.difficultyID <= difID)
        {
            for(int i=0; i<this.attackSelection.Length; i++)
            {
                if(this.actionDifficultyID[i] <= difID)
                {
                    if(valid == -2 && c.attackPartyTarget && DataHolder.BattleControl().HasPartyTarget())
                    {
                        action.targetID = DataHolder.BattleControl().GetPartyTargetID();
                    }
                    else if(valid == -2 && c.attackLastTarget && c.lastTargetBattleID >= 0 &&
                        DataHolder.BattleSystem().CheckForID(c.lastTargetBattleID, enemies, true))
                    {
                        action.targetID = c.lastTargetBattleID;
                    }
                    else
                    {
                        action.targetID = valid;
                    }
                    action.type = this.attackSelection[i];
                    // set up base attack
                    if(action.IsAttack() && !c.IsBlockAttack())
                    {
                        targetEnemy = true;
                        if(valid == -2)
                        {
                            if(c.aiNearestTarget)
                            {
                                action.targetID = c.GetNearestTarget(enemies);
                            }
                            else
                            {
                                action.targetID = c.GetRandomTarget(enemies);
                            }
                        }
                        found = true;
                    }
                    // set up skill
                    else if(action.IsSkill() && !c.IsBlockSkills() &&
                        c.HasSkill(this.useID[i], this.useLevel[i]) &&
                        DataHolder.Skill(this.useID[i]).CanUse(c, this.useLevel[i]-1))
                    {
                        action.useID = this.useID[i];
                        action.useLevel = this.useLevel[i]-1;
                        if(DataHolder.Skill(action.useID).TargetSelf())
                        {
                            action.targetID = c.battleID;
                        }
                        else if(DataHolder.Skill(action.useID).TargetNone())
                        {
                            action.targetID = BattleAction.NONE;
                            if(DataHolder.Skill(action.useID).targetRaycast.active)
                            {
                                GameObject target = null;
                                if(c.aiNearestTarget)
                                {
                                    if(DataHolder.Skill(action.useID).TargetEnemy())
                                    {
                                        target = c.GetNearestTargetObject(enemies);
                                    }
                                    else if(DataHolder.Skill(action.useID).TargetAlly())
                                    {
                                        target = c.GetNearestTargetObject(allies);
                                    }
                                }
                                else
                                {
                                    if(DataHolder.Skill(action.useID).TargetEnemy())
                                    {
                                        target = c.GetRandomTargetObject(enemies);
                                    }
                                    else if(DataHolder.Skill(action.useID).TargetAlly())
                                    {
                                        target = c.GetRandomTargetObject(allies);
                                    }
                                }
                                if(target != null)
                                {
                                    action.rayTargetSet = true;
                                    action.rayPoint = DataHolder.Skill(action.useID).targetRaycast.GetAIPoint(
                                            c.prefabInstance, target);
                                }
                            }
                        }
                        else if(DataHolder.Skill(action.useID).TargetAllyGroup() && c is Enemy)
                        {
                            action.targetID = BattleAction.ALL_ENEMIES;
                        }
                        else if(DataHolder.Skill(action.useID).TargetAllyGroup() && c is Character)
                        {
                            action.targetID = BattleAction.ALL_CHARACTERS;
                        }
                        else if(DataHolder.Skill(action.useID).TargetEnemyGroup() && c is Enemy)
                        {
                            action.targetID = BattleAction.ALL_CHARACTERS;
                            targetEnemy = true;
                        }
                        else if(DataHolder.Skill(action.useID).TargetEnemyGroup() && c is Character)
                        {
                            action.targetID = BattleAction.ALL_ENEMIES;
                            targetEnemy = true;
                        }
                        else if(DataHolder.Skill(action.useID).TargetSingleAlly())
                        {
                            if(valid == -2 || !DataHolder.BattleSystem().CheckForID(valid, allies,
                                !DataHolder.Skill(action.useID).level[action.useLevel].revive))
                            {
                                if(c.aiNearestTarget)
                                {
                                    action.targetID = c.GetNearestTarget(allies);
                                }
                                else
                                {
                                    action.targetID = c.GetRandomTarget(allies);
                                }
                            }
                        }
                        else if(DataHolder.Skill(action.useID).TargetSingleEnemy())
                        {
                            if(valid == -2 || !DataHolder.BattleSystem().CheckForID(valid, enemies, true))
                            {
                                if(c.aiNearestTarget)
                                {
                                    action.targetID = c.GetNearestTarget(enemies);
                                }
                                else
                                {
                                    action.targetID = c.GetRandomTarget(enemies);
                                }
                            }
                            targetEnemy = true;
                        }
                        found = true;
                    }
                    // set up item
                    else if(action.IsItem() && !c.IsBlockItems() &&
                        (!(c is Character) || GameHandler.HasItem(this.useID[i], 1)))
                    {
                        action.useID = this.useID[i];
                        if(DataHolder.Item(action.useID).TargetSelf())
                        {
                            action.targetID = c.battleID;
                        }
                        else if(DataHolder.Item(action.useID).TargetNone())
                        {
                            action.targetID = BattleAction.NONE;
                            if(DataHolder.Item(action.useID).targetRaycast.active)
                            {
                                GameObject target = null;
                                if(c.aiNearestTarget)
                                {
                                    if(DataHolder.Item(action.useID).TargetEnemy())
                                    {
                                        target = c.GetNearestTargetObject(enemies);
                                    }
                                    else if(DataHolder.Item(action.useID).TargetAlly())
                                    {
                                        target = c.GetNearestTargetObject(allies);
                                    }
                                }
                                else
                                {
                                    if(DataHolder.Item(action.useID).TargetEnemy())
                                    {
                                        target = c.GetRandomTargetObject(enemies);
                                    }
                                    else if(DataHolder.Item(action.useID).TargetAlly())
                                    {
                                        target = c.GetRandomTargetObject(allies);
                                    }
                                }
                                if(target != null)
                                {
                                    action.rayTargetSet = true;
                                    action.rayPoint = DataHolder.Item(action.useID).targetRaycast.GetAIPoint(
                                            c.prefabInstance, target);
                                }
                            }
                        }
                        else if(DataHolder.Item(action.useID).TargetAllyGroup() && c is Enemy)
                        {
                            action.targetID = BattleAction.ALL_ENEMIES;
                        }
                        else if(DataHolder.Item(action.useID).TargetAllyGroup() && c is Character)
                        {
                            action.targetID = BattleAction.ALL_CHARACTERS;
                        }
                        else if(DataHolder.Item(action.useID).TargetEnemyGroup() && c is Enemy)
                        {
                            action.targetID = BattleAction.ALL_CHARACTERS;
                            targetEnemy = true;
                        }
                        else if(DataHolder.Item(action.useID).TargetEnemyGroup() && c is Character)
                        {
                            action.targetID = BattleAction.ALL_ENEMIES;
                            targetEnemy = true;
                        }
                        else if(DataHolder.Item(action.useID).TargetSingleAlly())
                        {
                            if(valid == -2 || !DataHolder.BattleSystem().CheckForID(valid, allies,
                                !DataHolder.Item(action.useID).revive))
                            {
                                if(DataHolder.BattleSystem().IsRealTime())
                                {
                                    action.targetID = c.GetNearestTarget(allies);
                                }
                                else
                                {
                                    action.targetID = c.GetRandomTarget(allies);
                                }
                            }
                        }
                        else if(DataHolder.Item(action.useID).TargetSingleEnemy())
                        {
                            if(valid == -2 || !DataHolder.BattleSystem().CheckForID(valid, enemies, true))
                            {
                                if(DataHolder.BattleSystem().IsRealTime())
                                {
                                    action.targetID = c.GetNearestTarget(enemies);
                                }
                                else
                                {
                                    action.targetID = c.GetRandomTarget(enemies);
                                }
                            }
                            targetEnemy = true;
                        }
                        found = true;
                    }
                    else if(action.IsDefend() && !c.IsBlockDefend())
                    {
                        action.targetID = c.battleID;
                        found = true;
                    }
                    // set up escape
                    else if(action.IsEscape() && !c.IsBlockEscape())
                    {
                        action.targetID = c.battleID;
                        found = true;
                    }
                    else if(action.IsDeath() || action.IsNone())
                    {
                        action.targetID = c.battleID;
                        found = true;
                    }

                    // check active time
                    if(found)
                    {
                        if((DataHolder.BattleSystem().IsActiveTime() &&
                            c.usedTimeBar+action.GetTimeUse() > DataHolder.BattleSystem().maxTimebar) ||
                            (targetEnemy && enemies.Length == 0))
                        {
                            found = false;
                            targetEnemy = false;
                            action = new BattleAction();
                        }
                        else break;
                    }
                }
            }
        }

        if(!found) action = null;
        return action;
    }
Exemple #59
0
 public BattleMenuItem(GUIContent c, int i, string t, bool it, string inf, BattleAction a)
     : this(c, i, 0, t, it, inf, a)
 {
 }
Exemple #60
0
 public void setBattleAction(BattleAction battleAction)
 {
     this.battleAction = battleAction;
 }