Exemple #1
0
        public override Cast GetBestCast(Playfield p)
        {
            //DebugThings(p);
            Cast bc = null;

            Logger.Debug("Home = {Home}", p.home);

            #region Apollo Magic
            // Highest priority -> Can we kill the enemy with a spell
            BoardObj finisherTower = Decision.IsEnemyKillWithSpellPossible(p, out Handcard hc);
            if (finisherTower != null && (hc?.manacost > p.ownMana))
            {
                return(new Cast(hc.name, finisherTower.Position, hc));
            }
            // ------------------------------------------------------

            PlayfieldAnalyse.AnalyseLines(p);               // Danger- and Chancelevel
            currentSituation = GetCurrentFightState(p);     // Attack, Defense or UnderAttack (and where it is)
            hc = CardChoosing.GetOppositeCard(p, currentSituation) ?? CardChoosing.GetMobInPeace(p, currentSituation);
            //hc = CardChoosing.GetMobInPeace(p, currentSituation);

            if (hc == null)
            {
                Logger.Debug("Part: SpellApolloWay");
                Handcard hcApollo = SpellMagic(p, currentSituation, out VectorAI choosedPosition);

                if (hcApollo != null)
                {
                    hc = hcApollo;

                    if (choosedPosition != null && !(hc?.manacost > p.ownMana))
                    {
                        return(new Cast(hcApollo.name, choosedPosition, hcApollo));
                    }
                }
            }

            if (hc == null)
            {
                return(null);
            }

            Logger.Debug("Part: GetSpellPosition");

            VectorAI nextPosition = SpecialPositionHandling.GetPosition(p, hc);
            if (nextPosition == null)
            {
                nextPosition = PositionChoosing.GetNextSpellPosition(currentSituation, hc, p);
            }

            bc = new Cast(hc.name, nextPosition, hc);
            #endregion
            Logger.Debug("BestCast:" + bc.SpellName + " " + bc.Position.ToString());

            if (bc?.hc?.manacost > p.ownMana)
            {
                return(null);
            }
            return(bc);
        }
Exemple #2
0
        private static FightState GetCurrentFightStateBalanced()
        {
            FightState fightState = FightState.WAIT;

            if (GameBeginning)
            {
                return(GameBeginningDecision());
            }

            if (EnemyCharacterHandling.IsAnEnemyOnOurSide())
            {
                fightState = EnemyIsOnOurSideDecision();
            }
            else if (StaticValues.Player.Mana >= GameHandling.Settings.ManaTillAttack || AttackMode)
            {
                if (EnemyCharacterHandling.EnemiesWithoutTower.Count() > 2) // ToDo: CHeck more (Health, Damage etc)
                {
                    fightState = EnemyHasCharsOnTheFieldDecision();
                }
                else
                {
                    fightState = AttackDecision();
                }
            }

            Logger.Debug("FightSate = {0}", fightState.ToString());
            return(fightState);
        }
        private FightState GetCurrentState(int f)
        {
            FightState result;

            if (f == 0)
            {
                result = FightState.StartSwingPoint;
            }
            else if (f < fightHitTimePoint)
            {
                result = FightState.FrontSwing;
            }
            else if (f > fightHitTimePoint && lastState == FightState.FrontSwing)
            {
                result = FightState.HitPoint;
            }
            else if (f >= fightDuration)
            {
                result = FightState.FightEnd;
            }
            else
            {
                result = FightState.BackSwing;
            }

            lastState = result;
            return(result);
        }
Exemple #4
0
        public override void Update(UpdateState state)
        {
            switch (fightState)
            {
            case FightState.starting:
                if (fadeTime == 1f)
                {
                    fightWorld.Update(state);
                }

                fadeTime -= state.elapsedTime;
                activeBox.texture.filter = Color.Lerp(Color.White, Color.Transparent, fadeTime);
                if (fadeTime <= 0f)
                {
                    fightState = FightState.fighting;
                }

                break;

            case FightState.fighting:
                fightWorld.Update(state);
                fightTime += state.elapsedTime;

                if (fightTime >= 30f)
                {
                    fightTime = 0f;
                    EndFight();
                }
                break;
            }
        }
 private void Awake()
 {
     CurrentState = FightState.Introduction;
     Tutorial.SetActive(true);
     First.SetActive(false);
     Second.SetActive(false);
 }
 // Use this for initialization
 void Start()
 {
     currentState = FightState.Idle;
     cAnimator = GetComponentInParent<Animator>();
     Grid.EventHub.EnemyStartFight += onEnemyStartFight;
     Grid.EventHub.FightWin += onFightWin;
 }
 public void EndTurn()
 {
     for (int i = 0; i < buttons.Count; i++)
     {
         Destroy(buttons[i].gameObject);
     }
     buttons.Clear();
     Debug.Log(enemyCamp.currentHealth);
     if (leftPlayer.currentHealth == 0 || (isAgainstAI && enemyCamp.currentHealth == 0) || (!isAgainstAI && rightPlayer.currentHealth == 0))
     {
         fightstate = FightState.afterBattle;
     }
     else if (fightstate == FightState.leftTurn)
     {
         leftPlayer.BuffUpdateFight();
         fightstate = FightState.rightTurn;
     }
     else if (fightstate == FightState.rightTurn)
     {
         if (isAgainstAI)
         {
         }
         else
         {
             rightPlayer.BuffUpdateFight();
         }
         fightstate = FightState.leftTurn;
     }
     updateUI();
     StartCoroutine(NextState());
 }
Exemple #8
0
    /// <summary>
    /// Fade out and start the fighting
    /// </summary>
    /// <returns></returns>
    private IEnumerator FadeToClear()
    {
        Overlay.rectTransform.rect.Set(0, 0, Screen.width, Screen.height);
        Overlay.gameObject.SetActive(true);
        Overlay.color = Color.black;

        float rate = 1.0f / fadeTime;

        float progress = 0.0f;

        while (progress < 1.0f)
        {
            Overlay.color = Color.Lerp(Color.black, Color.clear, progress);

            progress += rate * Time.deltaTime;

            yield return(null);
        }

        Overlay.color = Color.clear;
        Overlay.gameObject.SetActive(false);
        State = FightState.Chosing;

        BeginFight();
    }
Exemple #9
0
 // Start is called before the first frame update
 void Start()
 {
     enemyAnim         = GetComponent <Animator>();
     currentFightState = FightState.BeginOfFight;
     ChangeFightStates();
     bossHealth.health = 500;
 }
Exemple #10
0
        public void SetMode_ShouldSetModeToPause()
        {
            var context = new Mocks().GetDefaultDatabaseContext();

            var fightEntity = new Fight
            {
                Id            = 1,
                BlueAthleteId = "abcd",
                RedAthleteId  = "efgh",
                Structure     = new FightStructure()
                {
                    Round = new Round()
                    {
                        BreakDuration = 1000,
                        Duration      = 3000,
                        RoundsCount   = 3
                    }
                }
            };

            context.Fights.Add(fightEntity);
            context.SaveChanges();

            var state = new FightState(context);

            state.Initialize(1);

            state.SetMode("pause");
            Assert.Equal(state.RemainingTime, 1000);
        }
Exemple #11
0
        private static IEnumerator DisplayFightResultFeedback(FightStatus fightStatus)
        {
            switch (GameStatus.fightType)
            {
            case FightType.None:
            case FightType.Versus:
                yield break;

            case FightType.BossFight:
                if (fightStatus.endReason != FightStatusEndReason.Lose)
                {
                    yield break;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();

            case FightType.TeamVersus:
                break;
            }
            FightState instance = FightState.instance;

            if (instance != null)
            {
                yield return(instance.ShowFightEndFeedback(fightStatus.endReason));
            }
            else
            {
                Log.Error("Could not find fight state.", 189, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FightEndedEvent.cs");
            }
        }
Exemple #12
0
    IEnumerator EnnemyTurn()
    {
        state = FightState.ENNEMY_TURN;
        float random = Random.Range(0f, 2f);

        if (random < 1f)
        {
            yield return(StartCoroutine(Attack(ennemy, player)));

            if (player.HP == 0)
            {
                StartCoroutine(EndGame(false));
            }
            else
            {
                EndRound(true);
            }
        }
        else if (1f < random && random < 2f)
        {
            yield return(StartCoroutine(Heal(ennemy)));

            EndRound(true);
        }
    }
Exemple #13
0
 void EndRound(bool won)
 {
     StartCoroutine(ChangeText("Fin de la manche"));
     state = FightState.END;
     panelAnimator.SetBool("FightPanelActive", false);
     onFightEnd.Invoke(won);
 }
Exemple #14
0
    private IEnumerator PlayerSkillThreeAttack()
    {
        state = FightState.ENEMYTURN;

        bool isDead = BattleLogicManager.AttackWithSkill(playerUnit, enemyUnit, playerUnit.equippedSkills[2]);

        enemyHUD.SetHP(enemyUnit.currentHP);
        playerHUD.SetMP(playerUnit.CurrentMP);

        yield return(new WaitForSeconds(2f));

        if (isDead)
        {
            state = FightState.WON;
            playerUnit.GainExperience(enemyUnit.rewardExp);
            playerUnit.GainGold(enemyUnit.rewardGold);
            EndFight(playerUnit, enemyUnit, 1);
        }
        else
        {
            enemyHUD.SetHP(enemyUnit.currentHP);
            enemyHUD.SetMP(enemyUnit.CurrentMP);
            playerHUD.SetHP(playerUnit.currentHP);
            playerHUD.SetMP(playerUnit.CurrentMP);

            StartCoroutine(EnemyTurn());
        }
    }
Exemple #15
0
    //0丢弃,1丢弃 2援助 3挑衅 4装死 5怒气
    public void OnAction(int id)
    {
        switch (id)
        {
        case 4:
            Main.Ins.LocalPlayer.PlaySkill();
            break;

        case 2:
            Main.Ins.LocalPlayer.ActionMgr.ChangeAction(CommonAction.Reborn);
            break;

        case 3:
            Main.Ins.LocalPlayer.ActionMgr.ChangeAction(CommonAction.Taunt);
            break;

        case 1:
            Main.Ins.LocalPlayer.ActionMgr.ChangeAction(CommonAction.Dead);
            break;

        case 5:
            if (FightState.Exist())
            {
                FightState.Instance.HideSkillBar();
            }
            break;
        }
    }
Exemple #16
0
    public void DieAnimHeroes()
    {
        if (Hero1Data.curHP <= 0)
        {
            anim1.SetTrigger("Die");
        }
        if (Hero2Data.curHP <= 0)
        {
            anim2.SetTrigger("Die");
        }
        if (Hero3Data.curHP <= 0)
        {
            anim3.SetTrigger("Die");
        }
        if (Hero4Data.curHP <= 0)
        {
            anim4.SetTrigger("Die");
        }

        if (Hero1Data.curHP + Hero2Data.curHP + Hero3Data.curHP + Hero4Data.curHP <= 0)
        {
            FightStates = FightState.END;
            StateControl();
        }
    }
Exemple #17
0
        private static Handcard SpellMagic(Playfield p, FightState currentSituation, out VectorAI choosedPosition)
        {
            choosedPosition = null;
            switch (currentSituation)
            {
            case FightState.UAKTL1:
            case FightState.UAKTL2:
            case FightState.UAPTL1:
            case FightState.UAPTL2:
            case FightState.DKT:
            case FightState.DPTL1:
            case FightState.DPTL2:
            case FightState.AKT:
            case FightState.APTL1:
            case FightState.APTL2:
                return(CardChoosing.All(p, currentSituation, out choosedPosition));

            case FightState.START:
                return(null);

            case FightState.WAIT:
                return(null);

            default:
                return(CardChoosing.All(p, currentSituation, out choosedPosition));
            }
        }
Exemple #18
0
 public FightManager(GameManager gameManager)
     : base(gameManager.world)
 {
     fightState       = FightState.idle;
     fightOver       += EndFight;
     this.gameManager = gameManager;
 }
Exemple #19
0
 public FightManager(GameManager gameManager)
     : base(gameManager.world)
 {
     fightState = FightState.idle;
     fightOver += EndFight;
     this.gameManager = gameManager;
 }
    void Awake()
    {
        homeSet         = false;
        survivorFood    = 0;
        survivorWater   = 0;
        survivorBandage = 0;
        survivorScrap   = 0;

        survivorHealth    = 100;
        survivorHunger    = 90;
        survivorThirst    = 90;
        survivorTiredness = 90;

        wayPointsList = new List <Vector3>();

        collectState  = new CollectState(this);
        buildState    = new BuildState(this);
        nourrishState = new NourrishState(this);
        fightState    = new FightState(this);
        repairState   = new RepairState(this);
        sleepState    = new SleepState(this);
        homeState     = new HomeState(this);
        healState     = new HealState(this);
        currentMap    = GameObject.Find("Map");
    }
Exemple #21
0
        private IEnumerator StartGame(FightInfo fightInfo)
        {
            StatesUtility.ClearOptionLayer();
            yield return(ApplyFightInfos(fightInfo));

            yield return(m_ui.GotoVersusAnim());

            yield return((object)new WaitForTime(2f));

            StateLayer   defaultLayer = StateManager.GetDefaultLayer();
            StateContext currentState = defaultLayer.GetChildState();

            if (currentState != null)
            {
                defaultLayer.ClearChildState(0);
                while ((int)currentState.get_loadState() == 8)
                {
                    yield return(null);
                }
            }
            FightState fightState = new FightState(fightInfo);

            defaultLayer.SetChildState(fightState, 0);
            VersusState versusState = new VersusState(m_ui, fightState);

            this.SetChildState(versusState, 0);
        }
Exemple #22
0
        private static CardTypeOld ChooseCardType(FightState currentSituation)
        {
            switch (currentSituation)
            {
            case FightState.UAKT:
            case FightState.UALPT:
            case FightState.UARPT:
                return(CardTypeOld.Defense);

            case FightState.AKT:
            case FightState.ALPT:
            case FightState.ARPT:
                return(CardTypeOld.All);

            case FightState.DKT:
            case FightState.DLPT:
            case FightState.DRPT:
                return(CardTypeOld.Troop);

            case FightState.START:
                return(CardTypeOld.NONE);

            case FightState.WAIT:
                return(CardTypeOld.NONE);

            default:
                return(CardTypeOld.All);
            }
        }
Exemple #23
0
        private static FightState GetCurrentFightStateBalanced(Playfield p)
        {
            FightState fightState = FightState.WAIT;

            if (Apollo.GameBeginning)
            {
                return(GameBeginningDecision(p));
            }

            if (!p.noEnemiesOnMySide())
            {
                fightState = EnemyIsOnOurSideDecision(p);
            }
            else if (p.ownMana >= Apollo.Settings.ManaTillAttack || (p.ownMinions.Count > 0))
            {
                if (p.enemyMinions.Count > 2)                 // ToDo: CHeck more (Health, Damage etc)
                {
                    fightState = EnemyHasCharsOnTheFieldDecision(p);
                }
                else
                {
                    fightState = AttackDecision(p);
                }
            }

            //Logger.Debug("FightSate = {0}", fightState.ToString());
            return(fightState);
        }
        public static Vector2f GetNextSpellPosition(FightState gameState, ICard card)
        {
            cardToDeploy = card;

            Vector2f choosedPosition = Vector2f.Zero, nextPosition;

            if (cardToDeploy is CardSpell)
            {
                return(GetPositionOfTheBestDamagingSpellDeploy());
            }

            // ToDo: Handle Defense Gamestates
            switch (gameState)
            {
            case FightState.UAKT:
                choosedPosition = UAKT();
                break;

            case FightState.UALPT:
                choosedPosition = UALPT();
                break;

            case FightState.UARPT:
                choosedPosition = UARPT();
                break;

            case FightState.AKT:
                choosedPosition = AKT();
                break;

            case FightState.ALPT:
                choosedPosition = ALPT();
                break;

            case FightState.ARPT:
                choosedPosition = ARPT();
                break;

            case FightState.DKT:
                choosedPosition = DKT();
                break;

            case FightState.DLPT:
                choosedPosition = DLPT();
                break;

            case FightState.DRPT:
                choosedPosition = DRPT();
                break;

            default:
                //Logger.Debug("GameState unknown");
                break;
            }
            Logger.Debug("GameState: {GameState}", gameState.ToString());
            nextPosition = choosedPosition;
            //Logger.Debug("nextPosition: " + nextPosition);

            return(nextPosition);
        }
Exemple #25
0
 public EnemyFactory(DiContainer container, FightState fightState, Transform enemyContainer, PlayerState playerState)
 {
     _container      = container;
     _fightState     = fightState;
     _enemyContainer = enemyContainer;
     _playerState    = playerState;
 }
 private static void OnCompanionInvocationLocationSelected(Target?targetOpt)
 {
     if (targetOpt.HasValue)
     {
         FightState instance = FightState.instance;
         bool       flag     = false;
         if (instance != null)
         {
             FightFrame frame = instance.frame;
             if (frame != null)
             {
                 Target value = targetOpt.Value;
                 frame.SendInvokeCompanion(s_companionBeingInvoked.definition.get_id(), value.coord);
                 flag = true;
             }
         }
         if (flag)
         {
             FightCastManager.OnUserActionEnd?.Invoke(FightCastState.Casting);
         }
         else
         {
             StopInvokingCompanion(cancelled: true);
         }
     }
     else
     {
         StopInvokingCompanion(cancelled: true);
     }
 }
Exemple #27
0
        public void Initialize_PassedFightId_ShouldReturnFreshState()
        {
            var fightEntity = new Fight
            {
                Id            = 1,
                BlueAthleteId = "abcd",
                RedAthleteId  = "efgh"
            };
            var context    = GetDefaultDatabaseContext();
            var fightState = new FightState(context);

            context.Fights.Add(fightEntity);
            context.SaveChanges();

            fightState.Initialize(1);
            var expected = new FightState(context)
            {
                BlueFighter = new Fighter("abcd", new List <FightPoint>()),
                RedFighter  = new Fighter("efgh", new List <FightPoint>()),
                Round       = 0,
                Id          = 1
            };

            Assert.Equal(expected, fightState);
        }
        public static ICard SpellMagic(FightState gameState)
        {
            if (ClashEngine.Instance.LocalPlayer == null)
            {
                return(null);
            }
            Spells = CardClassifying.Troop;

            CardTypeOld cardTypeToPlay = ChooseCardType(gameState);

            switch (cardTypeToPlay)
            {
            case CardTypeOld.All:
                return(AllSpellDecision());

            case CardTypeOld.Defense:
                return(DefenseSpellDecision());

            case CardTypeOld.Troop:
                return(DefenseTroopSpellDecision());

            case CardTypeOld.Buildings:
                return(BuildingsSpellDecision());

            case CardTypeOld.NONE:
                return(null);
            }
            return(null);
        }
        public static CardTypeOld ChooseCardType(FightState gameState)
        {
            switch (gameState)
            {
            case FightState.UAKT:
            case FightState.UALPT:
            case FightState.UARPT:
                return(CardTypeOld.Defense);

            case FightState.AKT:
            case FightState.ALPT:
            case FightState.ARPT:
                return(CardTypeOld.All);

            case FightState.DKT:
            case FightState.DLPT:
            case FightState.DRPT:
                return(CardTypeOld.Troop);

            case FightState.START:
                return(CardTypeOld.NONE);

            case FightState.WAIT:
                return(CardTypeOld.NONE);

            default:
                return(CardTypeOld.All);
            }
        }
Exemple #30
0
        private FighterBase CreateFighter()
        {
            FighterBase fighter;
            int         points = Constants.pointsNumber;

            Console.WriteLine("Назовите своего бойца\n");
            string name = Console.ReadLine();

            Console.WriteLine("\nВыберите класс героя:\n1: Воин\n2: Ловкач\n3: Маг");
            string fighterType = Console.ReadLine();

            switch (fighterType)
            {
            case "1":
                fighter = new Warrior(name);
                break;

            case "2":
                fighter = new Dodge(name);
                break;

            default:
                fighter = new Mage(name);
                break;
            }

            while (points > 0)
            {
                Console.Clear();
                Console.WriteLine(fighter);
                Console.WriteLine("Распределите очки умений среди характеристик персонажа:");
                Console.WriteLine("+1 Силы:      +{0} к урону", Constants.damageMultiplier);
                Console.WriteLine("+1 Ловкости:  +{0}% увернуться от атаки", Constants.dodgeMultiplier);
                Console.WriteLine("+1 Живучести: +{0} HP", Constants.hpMultiplier);
                Console.WriteLine();
                Console.WriteLine("Осталось очков умений: {0}", points);
                Console.WriteLine("1: +1 Силы");
                Console.WriteLine("2: +1 Ловкости");
                Console.WriteLine("3: +1 Живучести");
                switch (Console.ReadLine())
                {
                case "1":
                    fighter.Strength += 1;
                    break;

                case "2":
                    fighter.Agility += 1;
                    break;

                default:
                    fighter.Vitality += 1;
                    break;
                }
                points -= 1;
            }

            fighter.IsDead += () => fightState = FightState.Stopped;
            return(fighter);
        }
 public override void InitUIData()
 {
     base.InitUIData();
     m_WorldBossManager  = ObjectSelf.GetInstance().WorldBossMgr;
     m_FightState        = FightControler.Inst.GetFightState();
     m_AwardListLayout   = selfTransform.FindChild("AwardPanel/AwardList/Layout");
     m_OriginalAwardItem = selfTransform.FindChild("OriginalPanel/OriginalAwardItem").gameObject;
 }
Exemple #32
0
    //--------------------
    // FIGHT
    //--------------------

    private void InitializeFightState()
    {
        //Initialize fightstate if it is null
        if (fightState.amountOfEnemies == 0 && fightState.enemyBig == 0 && fightState.minDamage == 0 && fightState.maxDamage == 0)
        {
            fightState = new FightState(true);
        }
    }
Exemple #33
0
        public Fight(Characters.Character player1, Characters.Character player2, FightType type, Map map)
        {
            _fighters = new List<Fighter>();
            //_players = new List<Characters.Character>();
            //_players.Add(player1);
            //_players.Add(player2);

            _ID = map.NextFightID();
            _type = type;
            _state = FightState.Starting;
        }
Exemple #34
0
        public Fight(FightType type, Map map)
        {
            myID = map.NextFightID();
            myType = type;
            myState = FightState.STARTING;

            myMap = map;
            myTimer = new Timer(new TimerCallback(TimerLoop), null, 1000, 1000);

            Dictionary<int, int[]> places = GeneratePlaces();

            myTeam1 = new FightTeam(0, places[0]);
            myTeam2 = new FightTeam(1, places[1]);
        }
Exemple #35
0
        public void StartFight(Creature playerCreature, Creature otherCreature, Land land, Vector2 position)
        {
            fightWorld = new FightWorld(land, position, playerCreature, otherCreature);

            this.playerCreature = playerCreature;
            this.enemyCreature = otherCreature;

            Rectangle rect = gameManager.getActiveBoxArea();
            activeBox = new ActiveBox(gameManager.world, new Camera(rect.Width, rect.Height, fightWorld));
            activeBox.position = UserInterfaceManager.getUserInterfaceArea("activebox").getCenter();
            activeBox.texture.filter = Color.Transparent;

            fadeTime = 1f;
            fightState = FightState.starting;
        }
    // Update is called once per frame 	
    void Update()
    {
        switch (currentState)
        {
            case FightState.Delay:
                break;
            case FightState.WrongButtonPlayed:
                currentState = FightState.Delay;
                cAnimator.SetTrigger("Abort");
                Invoke("resetToFight", 3f);
                break;
            case FightState.ChordPlayingInIdle:
                currentState = FightState.Delay;
                Invoke("resetToIdle", 1f);
                break;
            case FightState.ChordPlayingInFight:
                currentState = FightState.Delay;
                if (lastKeyCorrect)
                {
                    Grid.EventHub.TriggerEnemyHit(this.gameObject, 1);
                    cAnimator.SetTrigger("Attack");
                    Invoke("resetToFight", 1f);
                }
                else
                {
                    Invoke("resetToWrongButtonPlayed", 1f);
                }
                break;
            case FightState.Idle:
                DoWhileIdle();
                break;

            case FightState.Fight:
                nextKey = GenerateNextAccord();
                cAnimator.SetTrigger(nextKey);
                currentState = FightState.WaitForPlayerInput;
                break;
            case FightState.WaitForPlayerInput:
                checkPlayerInput();
                break;


        }

    }
 private void resetToIdle()
 {
     currentState = FightState.Idle;
 }
 private void resetToWrongButtonPlayed()
 {
     currentState = FightState.WrongButtonPlayed;
 }
Exemple #39
0
        private void TurnStart()
        {
            NextFighter();

            myState = FightState.PLAYING;
            myTurnTimeOut = Environment.TickCount + TurnTime();

            myCurrentFighter.Buffs.OnTurnBegin();

            Send(FormatTurnStart());
        }
Exemple #40
0
 //Controls the InfoState which controls what is displayed on the RightSide of the screen...also calls upon MoveSelected()
 private void MoveSelection( MouseState mouse,  MouseState oldmouse,  Point mousepoint, Toon ChosenOne, Toon OpponentToon, Extras extra)
 {
     switch (OnToon)
     {
         case 0:
             ChosenOne.KeepGoingCheck(OpponentToon);
             if (ChosenOne.KeepGoing == true)
             {
                 HumanInterfaceMoveSelection(mouse, oldmouse, mousepoint, ChosenOne, OpponentToon, extra);
             }
             else
             {
                 State = FightState.Special;
                 ChosenOne.KeepGoing = true;
             }
             break;
         case 1:
             OpponentToon.KeepGoingCheck( ChosenOne);
             if (OpponentToon.KeepGoing == true)
             {
                 int OnMove = rand.Next(0, 4);
                 SelectedMove = OpponentToon.Ability[OnMove];
                 MoveSelected(OpponentToon, ChosenOne, OnMove, extra);
             }
             else
             {
                 State = FightState.Special;
                 OpponentToon.KeepGoing = false;
             }
             break;
     }
 }
Exemple #41
0
        private void SpecialCode(KeyboardState keyboard, KeyboardState oldkeyboard, Toon ChosenOne, Toon OpponentToon )
        {
            if (keyboard.IsKeyDown(Keys.Enter) && oldkeyboard.IsKeyUp(Keys.Enter))
            {
                if (OnToon == 0)
                {

                    DamageCalcCode(ChosenOne, OpponentToon);
                    State = FightState.Attack;
                }
                if (OnToon == 1)
                {

                    DamageCalcCode(OpponentToon, ChosenOne);
                    State = FightState.Attack;
                }

                firstTimeThrough = true;
                HaveResource = false;
            }
        }
Exemple #42
0
 private void TurnCode(Toon Activetoon, MouseState mouse, MouseState oldmouse, Point mousepoint, Toon ChosenOne, Toon OpponentToon, Extras extra)
 {
     ChosenOne.KeepGoing = true;
     OpponentToon.KeepGoing = true;
     FirstTimeThrough(Activetoon);
     if (possibleMove == false)
     {
         State = FightState.NoResource;
         firstTimeThrough = false;
     }
     else
     MoveSelection(mouse, oldmouse, mousepoint, ChosenOne, OpponentToon, extra);
 }
Exemple #43
0
    public AbstractState checkSight()
    {
        List<survivorAI> characters = FindsurvivorAIsInSight ();
        if (characters.Count == 0){
            //Debug.Log("do Search running!" + (Time.fixedTime - startSearch) );
            //RunState run = new RunState();
            //run.Parent = this;
            //run.survivorAI = this.survivorAI;
            //return run; //We have nothing to do, our next state is out current states

            Mover2 m = survivorAI.GetComponent<Mover2> ();

            if(m.found == true || (Time.fixedTime - startSearch) > 5.0f)
            {
                DayState run = new DayState(survivorAI);
                return run;
            }

            return this;
        }

        //We have to deal with the character that is getting close to the searcher

        float random = Random.value;
        if (random >= 0f && random <= 0.6f) {
            TalkState talk = new TalkState(survivorAI);
            talk.Parent = this;
            talk.Enemy = characters.First ();
            return talk;

        } else if(random >= 0.6f && random <= 0.8f)
        {
            FightState fight = new FightState(survivorAI);
            fight.Parent = this;
            fight.Enemy = characters.First();
            return fight;
        } else
        {
            RunState run = new RunState(survivorAI);
            run.Parent = this;
            run.Enemy = characters.First();
            return run;
        }
    }
Exemple #44
0
    /// <summary>
    /// Fade out and start the fighting
    /// </summary>
    /// <returns></returns>
    private IEnumerator FadeToClear()
    {
        Overlay.rectTransform.rect.Set(0, 0, Screen.width, Screen.height);
        Overlay.gameObject.SetActive(true);
        Overlay.color = Color.black;

        float rate = 1.0f / fadeTime;

        float progress = 0.0f;

        while (progress < 1.0f)
        {
            Overlay.color = Color.Lerp(Color.black, Color.clear, progress);

            progress += rate * Time.deltaTime;

            yield return null;
        }

        Overlay.color = Color.clear;
        Overlay.gameObject.SetActive(false);
        State = FightState.Chosing;

        BeginFight();
    }
Exemple #45
0
 void OnLevelWasLoaded(int level)
 {
     this.GetComponent<Canvas>().worldCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
     if (level == 1)
     {
         Destroy(OverworldObjects);
         StartCoroutine(FadeToClear());
         SetFighters();
         State = FightState.Begining;
     }
     else if (level == 0)
     {
         Destroy(FightObjects);
     }
 }
Exemple #46
0
        //Deals with what happens after a move has been selected... calls upon ResourceCheck, DamageCalcCode(),Toon.MoveCost(),
        private void MoveSelected(Toon ActiveToon, Toon OtherToon, int OnMove, Extras extra)
        {
            if (ActiveToon.CD[OnMove] == 0)
                {
                    ResourceCheck(ActiveToon, OnMove);
                    if (HaveResource == true)
                    {
                        SelectedMove = ActiveToon.Ability[OnMove];
                            ActiveToon.Ability[OnMove].BeenActive = 0;
                            DamageCalcCode(ActiveToon, OtherToon);
                            ActiveToon.MoveCost(SelectedMove, OnMove);
                            firstTimeThrough = true;
                            HaveResource = false;
                            State = FightState.Attack;
                            if (OtherToon.HP <= 0) // Game Ended
                            {
                                State = FightState.InitiliazeMoves;
                                extra.State = Extras.GameState.EndScreen;
                            }

                    }
                }
        }
Exemple #47
0
        public void TurnEnd()
        {
            SetAllTurnUnready();

            myState = FightState.WAITING;
            myWaitingTimeOut = Environment.TickCount + 5000;

            myCurrentFighter.SpellController.OnTurnEnd();
            myCurrentFighter.Buffs.OnTurnEnd();

            myCurrentFighter.AP = myCurrentFighter.Stats.GetStat(StatEnum.MaxPA).Total;
            myCurrentFighter.MP = myCurrentFighter.Stats.GetStat(StatEnum.MaxPM).Total;

            Send(FormatTurnStats());
            Send(FormatTurnEnd());
            Send(FormatTurnWait());
        }
Exemple #48
0
        public override void Update(UpdateState state)
        {
            switch (fightState)
            {
                case FightState.starting:
                    if(fadeTime == 1f)
                        fightWorld.Update(state);

                    fadeTime -= state.elapsedTime;
                    activeBox.texture.filter = Color.Lerp(Color.White, Color.Transparent, fadeTime);
                    if (fadeTime <= 0f)
                        fightState = FightState.fighting;

                    break;
                case FightState.fighting:
                    fightWorld.Update(state);
                    fightTime += state.elapsedTime;

                    if (fightTime >= 30f)
                    {
                        fightTime = 0f;
                        EndFight();
                    }
                    break;
            }
        }
    private void checkButton4()
    {
        if (lastKeyCorrect = nextKey.Equals(accordKeys[3]))
        {
            nextKey = GenerateNextAccord();
        }
        else
        {
            currentState = FightState.WrongButtonPlayed;
            nextKey = "";
        }

    }
Exemple #50
0
 public void TryStartFight(bool force = false)
 {
     if (IsAllReady && IsAvailableBattle() || force)
     {
         if (StartTimer != null)
         {
             this.StartTimer.Close();
             this.StartTimer.Stop();
             this.StartTimer.Enabled = false;
         }
         this.Map.HideFight(this);
         this.State = FightState.Fighting;
         this.TimeLine.RemixTimeLine();
         this.Send("GS");
         this.TimelineDisplay();
         this.TimeLine.StartTimelineTasks();
         this.InitChallenges();
     }
 }
    private void onFightWin(GameObject obj)
    {
        currentState = FightState.Idle;
        cAnimator.SetTrigger("Abort");
        Grid.EventHub.EnemyStartFight += onEnemyStartFight;

    }
Exemple #52
0
    public override AbstractState Update()
    {
        List<survivorAI> characters = FindsurvivorAIsInSight ();

        if (characters.Count == 0)
            return this; //We have nothing to do, our next state is out current states

        //We have to deal with the character that is getting close to our base

        float random = Random.value;
        if (random >= 0f && random <= 0.6f) {
            TalkState talk = new TalkState(survivorAI);
            talk.Parent = this;
            talk.Enemy = characters.First ();
            return talk;

        } else if(random >= 0.6f && random <= 0.8f)
        {
            FightState fight = new FightState(survivorAI);
            fight.Parent = this;
            fight.Enemy = characters.First();
            return fight;
        } else
        {
            RunState run = new RunState(survivorAI);
            run.Parent = this;
            run.Enemy = characters.First();
            return run;
        }
    }
 private void onEnemyStartFight(GameObject unused)
 {
     
     currentState = FightState.Fight;
     Grid.EventHub.EnemyStartFight -= onEnemyStartFight;
 }
Exemple #54
0
    public override AbstractState Update()
    {
        if (survivorAI.transform.position.magnitude < 1.5)
            return new GoBaseAI(this.survivorAI, this);

        if (!survivorAI.CanShoot ())
            return this;

        List<zombie> zombies = FindzombiesInSight ();

        if (zombies.Count == 0)
            return this; //We have nothing to do, our next state is out current states

        //We have to deal with the character that is getting close to our base

        FightState fight = new FightState(survivorAI);
        fight.Parent = this;
        fight.azombie = zombies.First();
        return fight;
    }
    private void DoWhileIdle()
    {

        if (Input.GetButtonDown("Fire1"))
        {
            PlayChord1();
            currentState = FightState.ChordPlayingInIdle;

        }
        if (Input.GetButtonDown("Fire2"))
        {
            PlayChord2();
            currentState = FightState.ChordPlayingInIdle;

        }
        if (Input.GetButtonDown("Fire3"))
        {
            PlayChord3();
            currentState = FightState.ChordPlayingInIdle;

        }
        if (Input.GetButtonDown("Jump"))
        {
            PlayChord4();
            currentState = FightState.ChordPlayingInIdle;

        }
    }
    private void checkPlayerInput()
    {
        if (Input.GetButtonDown("Fire1"))
        {
           checkButton1();
           if (lastKeyCorrect)
           {
               PlayChord1();
           }
           else
           {
               PlayChordFail();
           }
            currentState = FightState.ChordPlayingInFight;
        }

            if (Input.GetButtonDown("Fire2"))
            {
                checkButton2();
                 if (lastKeyCorrect)
           {
               PlayChord2();
           }
                 else
                
           {
               PlayChordFail();
           }
                currentState = FightState.ChordPlayingInFight;

            }

                if (Input.GetButtonDown("Fire3"))
                {
                   
                    checkButton3();
                    if (lastKeyCorrect)
                    {
                        PlayChord3();
                    }
                    else
                    {
                        PlayChordFail();
                    }
                    currentState = FightState.ChordPlayingInFight;

                }

                    if (Input.GetButtonDown("Jump"))
                    {
                        checkButton4();
                        if (lastKeyCorrect)
                        {
                            PlayChord4();
                        }
                        else
                        {
                            PlayChordFail();
                        }
                        currentState = FightState.ChordPlayingInFight;

                    }

    }
Exemple #57
0
        private void NoResourceCode(KeyboardState keyboard, KeyboardState oldkeyboard)
        {
            if (keyboard.IsKeyDown(Keys.Enter) && oldkeyboard.IsKeyUp(Keys.Enter))
            {
                if (OnToon == 0)
                    State = FightState.OpponentsTurn;
                if (OnToon == 1)
                    State = FightState.ChosenOnesTurn;

                firstTimeThrough = true;
                HaveResource = false;
            }
        }
 private void resetToFight()
 {
     currentState = FightState.Fight;
 }
Exemple #59
0
 private void InitializeMoves(Toon ChosenOne, Toon OpponentToon, IntMoves ManaMoves, StrMoves RageMoves, AgMoves EnergyMoves, LuckMoves luckMoves, Extras extra)
 {
     MoveChoice(OpponentToon, ChosenOne, ManaMoves, RageMoves, EnergyMoves, luckMoves,extra);
     MoveChoice(ChosenOne, OpponentToon, ManaMoves, RageMoves, EnergyMoves, luckMoves,extra);
     OnToon = rand.Next(0, 2);
     if (OnToon == 0)
         State = FightState.ChosenOnesTurn;
     if (OnToon == 1)
         State = FightState.OpponentsTurn;
 }
Exemple #60
0
        private void EndFight()
        {
            fightState = FightState.idle;
            enemyCreature.destroy();
            fightWorld = null;

            activeBox.destroy();
            gameManager.FightEnded();
        }