Esempio n. 1
0
 public BattleDamageEvent(Type type, BattleManager manager, BattleQueueTime time, BattleAgent target, Element element, int damage, DamageTo affects = DamageTo.HP) : base(type, manager, time)
 {
     Target  = target;
     Element = element;
     Damage  = damage;
     Affects = affects;
 }
Esempio n. 2
0
 public BattleSkillEvent(Type type, BattleManager manager, BattleQueueTime time, BattleAgent user, BattleAgent target, Skill skill) : base(type, manager, time)
 {
     User             = user;
     Target           = target;
     Skill            = skill;
     Power            = Skill.BasePower(user);
     IgnoreResistance = 0;
 }
Esempio n. 3
0
        public override BattleQueueTime Generate()
        {
            BattleQueueTime next = new BattleQueueTime(m_NextMinimum, m_NextMaximum);

            m_NextMinimum = m_NextMaximum;
            m_NextMaximum = 0.5f * (m_NextMaximum + m_AbsoluteMaximum);
            return(next);
        }
Esempio n. 4
0
        public override BattleQueueTime Generate()
        {
            BattleQueueTime next = new BattleQueueTime(m_NextMinimum, m_NextMaximum);

            m_NextMinimum += m_Difference;
            m_NextMaximum += m_Difference;
            return(next);
        }
Esempio n. 5
0
    public override void Execute(BattleManager manager, BattleQueueTime time)
    {
        BattleQueueTime.Generator t = new BattleQueueTime.FiniteGenerator(time, Sequence.Count);

        foreach (BattleAction action in Sequence)
        {
            manager.Add(new BattleActionExecution(t.Generate(), action));
        }
    }
Esempio n. 6
0
    public override void Execute(BattleManager manager, BattleQueueTime time)
    {
        BattleQueueTime.Generator timeAllTargets = new BattleQueueTime.InfiniteGenerator(time);

        int hpcost = Mathf.RoundToInt(HPCost * Skill.Cost(Agent));
        int spcost = Mathf.RoundToInt(SPCost * Skill.Cost(Agent));

        if (Agent.HP <= hpcost || Agent.SP < spcost)
        {
            return;
        }
        Agent.HP -= hpcost;
        Agent.SP -= spcost;

        foreach (Vector2Int point in Target)
        {
            BattleTile tile = manager.grid[point];
            if (tile != null && tile.Actor != null)
            {
                BattleQueueTime.Generator timeThisTarget = new BattleQueueTime.FiniteGenerator(timeAllTargets.Generate(), 5);
                BattleAgent target = tile.Actor.Agent;

                // Trigger any events before the user uses the skill
                BattleSkillEvent eventInfo = new BattleSkillEvent(
                    BattleEvent.Type.BeforeUseSkill,
                    manager,
                    timeThisTarget.Generate(),
                    Agent,
                    target,
                    Skill
                    );
                eventInfo.Power = Mathf.RoundToInt(eventInfo.Power * Power);
                Agent.OnTrigger(eventInfo);

                // Trigger any events before the target is targeted by the skill
                eventInfo.Time  = timeThisTarget.Generate();
                eventInfo.Event = BattleEvent.Type.BeforeTargetedBySkill;
                target.OnTrigger(eventInfo);

                // Animate the skill
                if (Skill.Animation != null)
                {
                    manager.Add(new BattleSpecialEffectAnimation(timeThisTarget.Generate(), Skill.Animation, eventInfo.Target));
                }

                // Make the skill happen
                eventInfo.Time = timeThisTarget.Generate();
                Skill.Execute(eventInfo);

                // Trigger any events after the target is targeted by the skill
                eventInfo.Time  = timeThisTarget.Generate();
                eventInfo.Event = BattleEvent.Type.AfterTargetedBySkill;
                target.OnTrigger(eventInfo);
            }
        }
    }
Esempio n. 7
0
    public override void Execute(BattleManager manager, BattleQueueTime time)
    {
        BattleDamageEvent eventInfo = new BattleDamageEvent(
            BattleEvent.Type.BeforeTakeDamage,
            manager,
            time,
            m_Agent,
            m_Element,
            m_Damage
            );

        m_Agent.Damage(eventInfo);
    }
Esempio n. 8
0
    public override void Execute(BattleManager manager, BattleQueueTime time)
    {
        m_Agent.OnTrigger(new BattleEvent(BattleEvent.Type.AfterTurn, manager, time));

        m_Agent.CP -= 60;
        if (m_Agent["Turn:Move"] <= 0)
        {
            m_Agent.CP -= 15;
        }
        if (m_Agent["Turn:Action"] <= 0)
        {
            m_Agent.CP -= 25;
        }
    }
Esempio n. 9
0
    /// <summary>
    /// Inflict the agent with a status effect.
    /// </summary>
    /// <param name="status">The status effect to inflict</param>
    /// <param name="duration">The duration of the status effect</param>
    public void Inflict(Status status, int duration, BattleQueueTime time, string message = "")
    {
        BattleManager manager = GameObject.FindObjectOfType <BattleManager>();

        if (StatusEffects.ContainsKey(status))
        {
            StatusEffects[status]["Duration"] += duration;
        }
        else
        {
            StatusEffects[status] = new StatusInstance(status, duration);

            BattleEvent eventInfo = new BattleEvent(BattleEvent.Type.FirstInflictedWithStatus, manager, time);
            status.OnTrigger(new StatusEvent(eventInfo, status, StatusEffects[status], this));
        }

        if (!message.Equals(""))
        {
            manager.Add(new BattleShowAgentMessage(time, manager, this, message));
        }
    }
Esempio n. 10
0
    public override void Execute(BattleManager manager, BattleQueueTime time)
    {
        // Find a path using A*
        Stack <Vector2Int> steps;

        PathFinder.AStar(m_Agent.Coordinates, destination, out steps, m_Agent["Jump"]);

        // Push each step in path
        BattleGrid grid = manager.grid;

        while (steps.Count > 1)
        {
            Vector2Int current = steps.Pop();

            if (grid[current].Height != grid[steps.Peek()].Height)
            {
                manager.Add(new BattleJump(current, steps.Peek() - current, time - steps.Count - 2));
            }
            else
            {
                manager.Add(new BattleWalk(current, steps.Peek() - current, time - steps.Count - 2));
            }
        }
    }
Esempio n. 11
0
 public BattleShowAgentReport(BattleQueueTime time, BattleAgent agent) : base(time)
 {
     m_Agent    = agent;
     m_ReportUI = GameObject.Find("Battle Agent Report UI").GetComponent <BattleAgentReportUI>();
 }
Esempio n. 12
0
 public BattleShowAgentMessage(BattleQueueTime time, BattleManager manager, BattleAgent agent, string message) : this(time, manager, agent, message, Color.white)
 {
 }
Esempio n. 13
0
 public BattleShowAgentDialogue(BattleQueueTime time, BattleAgent speaker, string text) : base(time)
 {
     m_Speaker = speaker;
     m_Text    = text;
 }
Esempio n. 14
0
 public override void Execute(BattleManager manager, BattleQueueTime time)
 {
     manager.Add(new BattleShowAgentDialogue(time, m_Speaker, m_Text));
 }
Esempio n. 15
0
 public BattleAgentDecision(BattleQueueTime time, BattleAgent agent) : base(time)
 {
     m_Agent   = agent;
     m_Decider = null;
 }
Esempio n. 16
0
 public BattleTargetConfirm(BattleQueueTime time, BattleZone range, BattleManhattanDistanceZone target) : base(time)
 {
     m_Range  = range;
     m_Target = target;
 }
Esempio n. 17
0
 public BattleShowAgentMessage(BattleQueueTime time, BattleManager manager, BattleAgent agent, string message, Color color) : base(time)
 {
     m_Actor   = manager.grid[agent.Coordinates].Actor;
     m_Message = message;
     m_Color   = color;
 }
Esempio n. 18
0
 public InfiniteGenerator(BattleQueueTime span)
 {
     m_AbsoluteMaximum = span.m_Maximum;
     m_NextMinimum     = span.m_Minimum;
     m_NextMaximum     = 0.5f * (span.m_Minimum + span.m_Maximum);
 }
Esempio n. 19
0
 public BattleActionEvent(Type eventType, BattleManager manager, BattleQueueTime time, T action) : base(eventType, manager, time)
 {
     Action = action;
 }
Esempio n. 20
0
 public FiniteGenerator(BattleQueueTime span, int number)
 {
     m_Difference  = (span.m_Maximum - span.m_Minimum) / number;
     m_NextMinimum = span.m_Minimum;
     m_NextMaximum = m_NextMinimum + m_Difference;
 }
Esempio n. 21
0
 public BattleTargetSelect(BattleQueueTime time, BattleZone range) : base(time)
 {
     m_Range = range;
 }
Esempio n. 22
0
 public abstract void Execute(BattleManager manager, BattleQueueTime time);
Esempio n. 23
0
 public BattleActionExecution(BattleQueueTime time, BattleAction action) : base(time)
 {
     m_Action = action;
 }
Esempio n. 24
0
 public override void Execute(BattleManager manager, BattleQueueTime time)
 {
     manager.Add(new BattleShowAgentReport(time - 1f, m_Agent));
 }
Esempio n. 25
0
 public BattleQueueMember(BattleQueueTime time)
 {
     this.time = time;
 }
Esempio n. 26
0
 public BattleEvent(Type eventType, BattleManager manager, BattleQueueTime time)
 {
     Event   = eventType;
     Manager = manager;
     Time    = time;
 }
 public BattleSpecialEffectAnimation(BattleQueueTime time, BattleSpriteAnimation animation, BattleAgent agent) : base(time)
 {
     m_Animation = animation;
     m_Agent     = agent;
 }
Esempio n. 28
0
 public BattleWalk(Vector2Int coordinates, Vector2Int direction, BattleQueueTime time) : base(time)
 {
     m_Source    = coordinates;
     m_Direction = direction;
     m_Velocity  = WalkSpeed * new Vector3(direction.x, 0f, -direction.y);
 }