Ejemplo n.º 1
0
    // 吟唱阶段
    private void OnAbilityPhaseStart()
    {
        BattleLog.Log("【吟唱阶段】OnAbilityPhaseStart" + m_AbilityData.configFileName);

        abilityState = AbilityState.CastPoint;
        ExecuteEvent(AbilityEvent.OnAbilityPhaseStart);
    }
    //Starting a fight,, and determing who is winner and loser in dance off
    IEnumerator DoRound()
    {
        yield return(new WaitForSeconds(battlePrepTime));

        //checking for no dancers on either team
        if (TeamA.activeDancers.Count > 0 && TeamB.activeDancers.Count > 0)
        {
            int i = Random.Range(0, TeamA.activeDancers.Count);
            int j = Random.Range(0, TeamB.activeDancers.Count);

            Character characterA = TeamA.activeDancers[i];
            Character characterB = TeamB.activeDancers[j];
            GameEvents.RequestFight(new FightEventData(characterA, characterB));
        }
        else
        {
            DanceTeam winner;

            winner = TeamA.activeDancers.Count <= 0 ? TeamB : TeamA;


            GameEvents.BattleFinished(winner);
            winner.EnableWinEffects();

            BattleLog.Log(new DefaultLogMessage("the winning team is: " + winner.troupeNameText, winner.teamColor));

            //log it battlelog also
            //Debug.Log("DoRound called, but we have a winner so Game Over");
        }
    }
Ejemplo n.º 3
0
    protected override void onEnter(TBTWorkingData wData)
    {
        BattleBehaviorWorkingData behaviorData = wData as BattleBehaviorWorkingData;
        BattleUnit source  = behaviorData.owner;
        Ability    ability = source.SelectCastableAbility();

        BattleLog.Log("【NOD_CastAbility】onEnter {0}", ability.GetConfigName());

        source.CastAbility(ability);
    }
Ejemplo n.º 4
0
    protected override void onEnter(TBTWorkingData wData)
    {
        BattleLog.Log("【NOD_SetUnitIdle】onEnter");
        BattleBehaviorWorkingData behaviorData = wData as BattleBehaviorWorkingData;
        BattleUnit source  = behaviorData.owner;
        var        request = behaviorData.request;

        source.SetState(HeroState.IDLE);
        request.isRequestCompleted = true;
    }
Ejemplo n.º 5
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();



        yield return(new WaitForSeconds(fightAnimTime));

        float outcome = 0;
        //defaulting to draw
        Character winner = lhs, defeated = rhs;


        float rhsoutcome = lhs.luck * lhs.rhythm - lhs.style / (lhs.xp + Random.Range(8, 19));

        float lhsoutcome = rhs.luck * rhs.rhythm - rhs.style / (rhs.xp + Random.Range(0, 12));

        if (lhsoutcome < rhsoutcome)
        {
            winner   = lhs;
            defeated = rhs;
            outcome  = -1;
        }
        else
        {
            winner   = rhs;
            defeated = lhs;
            outcome  = 1;
        }

        if (outcome != 0)
        {
            BattleLog.Log(new DefaultLogMessage(winner.charName.GetFullCharacterName() + "Wins", winner.myTeam.teamColor));
        }
        else
        {
            //draw
            BattleLog.Log(new DefaultLogMessage(lhs.charName.GetFullCharacterName() + "ties with" + rhs.charName.GetFullCharacterName(), drawCol));
        }
        // Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        //Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Ejemplo n.º 6
0
    public void ExecuteEvent(AbilityEvent abilityEvent, BattleUnit source, RequestTarget requestTarget)
    {
        BattleLog.Log("【AbilityData】ExecuteEvent:{0},source:{1},target:{2}", abilityEvent.ToString(), source.GetName(), requestTarget.ToString());

        string  eventName = Enum.GetName(typeof(AbilityEvent), abilityEvent);
        D2Event @event;

        eventMap.TryGetValue(eventName, out @event);
        if (@event != null)
        {
            @event.Execute(source, this, requestTarget);
        }
    }
Ejemplo n.º 7
0
    //TODO this function is all you need to modify, in this script.
    //You just need determine who wins/loses/draws etc.
    IEnumerator Attack(Character teamACharacter, Character teamBCharacter)
    {
        float     outcome  = 0;              // the outcome from the fight, i.e. the % that the winner has won by...fractions could help us calculate this, but start with whole numbers i.e. 0 = draw, and 1 = 100% win.
        Character winner   = teamACharacter; //defaulting the winner to TeamA.
        Character defeated = teamBCharacter; //defaulting the loser to TeamB.

        // Tells each dancer that they are selcted and sets the animation to dance.
        SetUpAttack(teamACharacter);
        SetUpAttack(teamBCharacter);

        // Tells the system to wait X number of seconds until the fight to begins.
        yield return(new WaitForSeconds(fightAnimTime));

        // We want to get some battle points from each of our characters...instead of just 0....is there a function in the Character script that could help us?
        int teamABattlePoints = teamACharacter.ReturnBattlePoints();
        int teamBBattlePoints = teamBCharacter.ReturnBattlePoints();


        if (teamABattlePoints <= 0 || teamBBattlePoints <= 0)
        {
            Debug.LogWarning("Player or NPC battle points is 0, most likely the logic has not be setup for this yet");
        }
        Debug.Log(teamABattlePoints);
        Debug.Log(teamBBattlePoints);
        if (teamABattlePoints > teamBBattlePoints)
        {
            outcome = 1 - ((float)teamBBattlePoints / (float)teamABattlePoints);
            Debug.Log("raw wins");
            winner   = teamACharacter;
            defeated = teamBCharacter;
            BattleLog.Log("Raw wins!", winner.myTeam.teamColor);
        }
        else if (teamABattlePoints < teamBBattlePoints)
        {
            outcome = 1 - ((float)teamBBattlePoints / (float)teamABattlePoints);
            Debug.Log("smackdown wins");
            defeated = teamACharacter;
            BattleLog.Log("Smackdown wins!", winner.myTeam.teamColor);
        }
        else
        {
            BattleLog.Log("Fight is a draw!", drawCol);
        }


        Debug.LogWarning("Attack called, may want to use the BattleLog.Log() to report the dancers and the outcome of their dance off.");

        // Pass on the winner/loser and the outcome to our fight completed function.
        FightCompleted(winner, defeated, outcome);
        yield return(null);
    }
Ejemplo n.º 8
0
    // In this script there is a dance off results between dancers.
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        float lhsresult;
        float rhsresult;
        float outcome;

        yield return(new WaitForSeconds(fightAnimTime));

        lhsresult = Random.Range(-1.0f, (lhs.luck * Random.Range(-1, lhs.luck)) + (1 / (lhs.rhythm * lhs.style + 1)) + 1);
        rhsresult = Random.Range(-1.0f, (rhs.luck * Random.Range(-1, rhs.luck)) + (1 / (rhs.rhythm * rhs.style + 1)) + 1);

        Character winner = lhs, defeated = rhs;

        if (lhsresult > rhsresult)
        {
            winner   = lhs;
            defeated = rhs;
            outcome  = lhsresult;
        }
        else
        {
            winner   = rhs;
            defeated = lhs;
            outcome  = rhsresult;
        }


        BattleLog.Log(new DefaultLogMessage("the winner character is " + winner.charName.GetFullCharacterName(), winner.myTeam.teamColor));
        BattleLog.Log(new DefaultLogMessage("the loser character is " + defeated.charName.GetFullCharacterName(), defeated.myTeam.teamColor));

        //defaulting to draw
        //Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");


        //Debug.LogWarning("Attack called, may want to use the BattleLog to report the dancers and the outcome of their dance off.");


        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);


        yield return(null);
    }
Ejemplo n.º 9
0
    public override bool IsTrue(TBTWorkingData wData = null)
    {
        // 判断物体是否在视野范围内
        BattleBehaviorWorkingData data    = wData as BattleBehaviorWorkingData;
        AIBehaviorRequest         request = data.request;
        BattleUnit owner          = data.owner;
        float      viewRange      = owner.GetViewRange();
        Vector2    targetPos      = request.target.Get2DPosition();
        Vector2    ownerPos       = owner.Get2DPosition();
        float      distanceSquare = (targetPos - ownerPos).magnitude;

        BattleLog.Log(string.Format("【CON_IsInRange】距离:{0},可见范围:{1}", distanceSquare, viewRange * viewRange));
        return(distanceSquare <= viewRange * viewRange);
    }
Ejemplo n.º 10
0
    // 施法阶段
    private void OnSpellStart()
    {
        BattleLog.Log("【施法阶段】OnSpellStart" + m_AbilityData.configFileName);

        if (m_AbilityData.channelTime > 0)
        {
            abilityState = AbilityState.Channeling;
        }
        else
        {
            abilityState = AbilityState.CastBackSwing;
        }

        ExecuteEvent(AbilityEvent.OnSpellStart);
    }
Ejemplo n.º 11
0
    IEnumerator Attack(Character lhs, Character rhs)
    {
        lhs.isSelected = true;
        rhs.isSelected = true;
        lhs.GetComponent <AnimationController>().Dance();
        rhs.GetComponent <AnimationController>().Dance();

        yield return(new WaitForSeconds(fightAnimTime));

        float outcome = 0;
        //defaulting to draw
        Character winner = lhs, defeated = rhs;

        //Debug.LogWarning("Attack called, needs to use character stats to determine winner with win strength from 1 to -1. This can most likely be ported from previous brief work.");
        outcome = (rhs.rhythm / rhs.style + rhs.luck) - (lhs.rhythm / lhs.style + lhs.luck);
        outcome = Mathf.Clamp(outcome, -1f, 1f);
        if (outcome > 0)
        {
            winner   = rhs;
            defeated = lhs;
        }
        else if (outcome < 0)
        {
            winner   = lhs;
            defeated = rhs;
        }
        else
        {
            Debug.Log("It's a draw");
        }

        if (outcome != 0)
        {
            BattleLog.Log(new DefaultLogMessage(winner.charName.GetFullCharacterName() + " is the Winnner!", winner.myTeam.teamColor));
        }
        else
        {
            BattleLog.Log(new DefaultLogMessage(lhs.charName.GetFullCharacterName() + " ties with " + rhs.charName.GetFullCharacterName(), drawCol));
        }

        var results = new FightResultData(winner, defeated, outcome);

        lhs.isSelected = false;
        rhs.isSelected = false;
        GameEvents.FightCompleted(results);

        yield return(null);
    }
Ejemplo n.º 12
0
    public virtual void Execute(BattleUnit source, AbilityData abilityData, RequestTarget requestTarget)
    {
        this.abilityData   = abilityData;
        this.requestTarget = requestTarget;

        var targetCollection = TargetSearcher.instance.GetActionTargets(source, abilityData, requestTarget, actionTarget);

        BattleLog.Log("【D2Action】{0}, source:{1},target:{2}", GetType().Name, source.GetName(), requestTarget.ToString());
        // 根据类型区分,单位和范围
        if (requestTarget.targetType == AbilityRequestTargetType.UNIT)
        {
            ExecuteByUnit(source, targetCollection.units);
        }
        else
        {
            ExecuteByPoint(source, targetCollection.points);
        }
    }
Ejemplo n.º 13
0
    public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed.

    /// <summary>
    /// This occurs every round or every X number of seconds, is the core battle logic/game loop.
    /// </summary>
    /// <returns></returns>
    IEnumerator DoRound()
    {
        // waits for a float number of seconds....
        yield return(new WaitForSeconds(battlePrepTime));

        //checking for no dancers on either team
        if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0)
        {
            Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed");
            // This will be called if there are 0 dancers on both teams.
        }
        else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0)
        {
            Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below");
            //Randomly select two characters, one from each team
            Character characterA = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)];
            Character characterB = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)];

            //Make them fight
            fightManager.Fight(characterA, characterB);
        }
        else
        {
            DanceTeam winner;


            if (teamA.activeDancers.Count > 0)
            {
                winner = teamA;
            }
            else
            {
                winner = teamB;
            }


            //Enables the win effects, and logs it out to the console.
            winner.EnableWinEffects();
            BattleLog.Log(winner.ToString(), winner.teamColor);

            Debug.Log("DoRound called, but we have a winner so Game Over");
        }
    }
Ejemplo n.º 14
0
    public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed.

    /// <summary>
    /// This occurs every round or every X number of seconds, is the core battle logic/game loop.
    /// </summary>
    /// <returns></returns>
    IEnumerator DoRound()
    {
        // waits for a float number of seconds....
        yield return(new WaitForSeconds(battlePrepTime));

        //checking for no dancers on either team
        if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0)
        {
            Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed");
            // This will be called if there are 0 dancers on both teams.
        }
        else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0)
        {
            Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below");
            //You need to select two random or engineered random characters to fight...so one from team a and one from team b....
            //We then need to pass in the two selected dancers into fightManager.Fight(CharacterA,CharacterB);
            //fightManager.Fight(charA, charB);
            Character characterA = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)];
            Character characterB = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)];
            fightManager.Fight(characterA, characterB);
        }
        else
        {
            // IF we get to here...then we have a team has won...winner winner chicken dinner

            // We need to determine a winner...but how?...maybe look at the previous if statements for clues?
            if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count == 0)
            {
                teamA.EnableWinEffects();
                BattleLog.Log(teamA.danceTeamName, teamA.teamColor);
            }

            else if (teamB.activeDancers.Count > 0 && teamA.activeDancers.Count == 0)
            {
                teamB.EnableWinEffects();
                BattleLog.Log(teamB.danceTeamName, teamB.teamColor);
            }



            Debug.Log("DoRound called, but we have a winner so Game Over");
        }
    }
Ejemplo n.º 15
0
    protected override void onEnter(TBTWorkingData wData)
    {
        base.onEnter(wData);
        BattleDecisionWorkingData decisionData = wData as BattleDecisionWorkingData;
        BattleUnit caster  = decisionData.owner;
        Ability    ability = caster.SelectCastableAbility();

        if (ability == null)
        {
            // 没有技能就追逐
            var request = decisionData.request;
            if (request == null || (request != null && request.IsRequestCompleted()))
            {
                var chaseTarget = caster.target;
                if (chaseTarget == null)
                {
                    chaseTarget = TargetSearcher.instance.FindNearestEnemyUnit(caster);
                }

                if (chaseTarget != null)
                {
                    m_chaseRequest       = new ChaseRequest(chaseTarget);
                    decisionData.request = m_chaseRequest;
                }
                else
                {
                    //idle
                }
            }
        }
        else
        {
            // 寻找技能目标, 如果有目标被放逐了,可能就选不到目标!
            BattleUnit target = TargetSearcher.instance.FindTargetUnitByAbility(caster, ability);
            if (target != null)
            {
                BattleLog.Log("【NOD_UpdateRequest】选取到技能ability:{0},target:{1}", ability.GetConfigName(), target.GetName());
                m_autoCastAbilityRequest = new AutoCastAbilityRequest(ability, target);
                decisionData.request     = m_autoCastAbilityRequest;
            }
        }
    }
Ejemplo n.º 16
0
    public float fightCompletedWaitTime = 2; // the amount of time we need to wait till a fight/round is completed.

    /// <summary>
    /// This occurs every round or every X number of seconds, is the core battle logic/game loop.
    /// </summary>
    /// <returns></returns>
    IEnumerator DoRound()
    {
        // waits for a float number of seconds....
        yield return(new WaitForSeconds(battlePrepTime));

        //checking for no dancers on either team
        if (teamA.allDancers.Count == 0 && teamB.allDancers.Count == 0)
        {
            Debug.LogWarning("DoRound called, but there are no dancers on either team. DanceTeamInit needs to be completed");
            // This will be called if there are 0 dancers on both teams.
        }
        else if (teamA.activeDancers.Count > 0 && teamB.activeDancers.Count > 0)
        {
            Debug.LogWarning("DoRound called, it needs to select a dancer from each team to dance off and put in the FightEventData below");

            //Randomly chooses team members to compete against each other
            Character teamAChosenOne = teamA.activeDancers[Random.Range(0, teamA.activeDancers.Count)];
            Character teamBChosenOne = teamB.activeDancers[Random.Range(0, teamB.activeDancers.Count)];

            fightManager.Fight(teamAChosenOne, teamBChosenOne);
        }
        else
        {
            //Sets the winning team based off who still has dancers.
            DanceTeam winner = null;

            if (teamA.activeDancers.Count > 0)
            {
                winner = teamA;
            }
            else if (teamB.activeDancers.Count > 0)
            {
                winner = teamB;
            }

            //Enables the win effects, and logs it out to the console.
            winner.EnableWinEffects();
            BattleLog.Log(winner.ToString(), winner.teamColor);

            Debug.Log("DoRound called, but we have a winner so Game Over");
        }
    }
Ejemplo n.º 17
0
    public virtual void OnUse()
    {
        BattleLog.Log(isHeld ? UseWhileHeldMessage : UseNotHeldMessage);
        if (usedSFX != null)
        {
            usedSFX.Play2D();
        }

        if (usedEventsHolder != null)
        {
            if (isHeld)
            {
                usedEventsHolder.OnUsedWhileHeld.Invoke();
            }
            else
            {
                usedEventsHolder.OnUsedWhileNotHeld.Invoke();
            }
        }
    }
Ejemplo n.º 18
0
    private float fightAnimTime = 2;          //An amount to wait between initiating the fight, and the fight begining, so we can see some of that sick dancing.


    IEnumerator Attack(Character teamACharacter, Character teamBCharacter)
    {
        Character winner;
        Character defeated;

        float charAPoints, charBPoints;

        charAPoints = (float)teamACharacter.ReturnBattlePoints();
        charBPoints = (float)teamBCharacter.ReturnBattlePoints();

        float outcome;

        if (charAPoints > charBPoints)
        {
            winner   = teamACharacter;
            defeated = teamBCharacter;
            outcome  = charAPoints / charBPoints - 1;
        }
        else
        {
            winner   = teamBCharacter;
            defeated = teamACharacter;
            outcome  = charBPoints / charAPoints - 1;
        }

        // Tells each dancer that they are selcted and sets the animation to dance.
        SetUpAttack(teamACharacter);
        SetUpAttack(teamBCharacter);

        // Tells the system to wait X number of seconds until the fight to begins.
        yield return(new WaitForSeconds(fightAnimTime));

        BattleLog.Log("Fight is over! The winner is " + winner.charName.GetFullCharacterName() + " with a score of " + outcome, drawCol);

        // Pass on the winner/loser and the outcome to our fight completed function.
        FightCompleted(winner, defeated, outcome);
        yield return(null);
    }
Ejemplo n.º 19
0
 /// <summary>
 /// Sets up a dancer to be selected and the animation to start dancing.
 /// </summary>
 /// <param name="dancer"></param>
 private void SetUpAttack(Character dancer)
 {
     dancer.isSelected = true;
     dancer.GetComponent <AnimationController>().Dance();
     BattleLog.Log(dancer.charName.GetFullCharacterName() + " Selected", dancer.myTeam.teamColor);
 }
Ejemplo n.º 20
0
 public void LogMessageNow()
 {
     BattleLog.Log(message);
 }
Ejemplo n.º 21
0
 protected override void onExit(TBTWorkingData wData, int runningStatus)
 {
     BattleLog.Log("【NOD_CastAbility】onExit");
 }