public CountdownState(BattleStateHandler battleStateHandler)
        {
            battleStateHandler.ServerCountdownTime = countdownInitial;

            nextSync = Time.time + syncIntervalSeconds;
            battleStateHandler.SyncCountdownTime();

            firstUpdate = true;
        }
        public IBattleState UpdateState(BattleStateHandler battleStateHandler)
        {
            if (battleStateHandler.ServerCountdownTime <= 0)
            {
                Debug.Log("Countdown done");

                battleStateHandler.timerAnimator.Play("TimerOut");

                return(new PlayerActionState());
            }
            return(this);
        }
Пример #3
0
        public IBattleState UpdateState(BattleStateHandler battleStateHandler)
        {
            if (battleStateHandler.enemy.IsDead())
            {
                return(new EndGameState(true));
            }

            bool animationDone = shotFired && this.fireBall == null;

            if (animationDone || actionTime <= 0)
            {
                if (enemyAction != null)
                {
                    enemyAction.Apply(battleStateHandler.player);
                    battleStateHandler.battleTextField.text = string.Format("JULIANA takes {0} damage!", enemyAction.damage);
                }
                return(new CountdownState(battleStateHandler));
            }
            return(this);
        }
Пример #4
0
        public void Update(BattleStateHandler battleStateHandler)
        {
            if (messageDisplayed)
            {
                return;
            }

            Image endImage;

            if (playerWin)
            {
                endImage = MonoBehaviour.Instantiate(battleStateHandler.winScreen, new Vector2(), Quaternion.identity) as Image;
            }
            else
            {
                endImage = MonoBehaviour.Instantiate(battleStateHandler.gameOverScreen, new Vector2(), Quaternion.identity) as Image;
            }
            endImage.transform.SetParent(battleStateHandler.canvas.transform, false);
            messageDisplayed = true;
            return;
        }
        public void Update(BattleStateHandler battleStateHandler)
        {
            if (Network.isServer)
            {
                if (Time.time > nextSync)
                {
                    nextSync = Time.time + syncIntervalSeconds;
                    battleStateHandler.SyncCountdownTime();
                }
            }

            if (firstUpdate)
            {
                firstUpdate = false;
                battleStateHandler.timerAnimator.Play("TimerIn");
            }

            battleStateHandler.ServerCountdownTime -= Time.deltaTime;

            battleStateHandler.timerDisplay.fillAmount = 1f - (battleStateHandler.ServerCountdownTime / CountdownState.countdownInitial);
        }
Пример #6
0
        public void Update(BattleStateHandler battleStateHandler)
        {
            if (initialDelayTime > 0)
            {
                initialDelayTime -= Time.deltaTime;
                return;
            }

            actionTime -= Time.deltaTime;

            if (battleStateHandler.currentFireMonsterState == BattleStateHandler.FireMonsterState.PARALYSED)
            {
                battleStateHandler.battleTextField.text = "The Fire Monster is paralysed!!";
                return;
            }

            if (battleStateHandler.enemy.IsDead())
            {
                Color enemyColor     = battleStateHandler.enemy.enemyImage.color;
                Color redEnemyColour = new Color(
                    1.0f,
                    0,
                    0,
                    enemyColor.a
                    );

                battleStateHandler.enemy.enemyImage.color = redEnemyColour;
                return;
            }

            if (!shotFired && battleStateHandler.currentFireMonsterState == BattleStateHandler.FireMonsterState.ATTACKING)
            {
                this.fireBall = MonoBehaviour.Instantiate(battleStateHandler.enemyFireballPrefab) as Image;
                this.fireBall.transform.SetParent(battleStateHandler.canvas.transform, false);
                shotFired = true;
            }

            // Take action
            enemyAction = new BattleAction(10);
        }
Пример #7
0
 public IBattleState UpdateState(BattleStateHandler battleStateHandler)
 {
     return(this);
 }
Пример #8
0
        public void Update(BattleStateHandler battleStateHandler)
        {
            actionTimeout -= Time.deltaTime;

            if (actionPerformed)
            {
                return;
            }

            if (Network.isServer)
            {
                int highestVotedAction = 0;

                if (battleStateHandler.highestVotedAction == 0)
                {
                    highestVotedAction = TallyVotes(Voting.ChosenOption);

                    battleStateHandler.networkView.RPC("FinaliseHighestVotedAction", RPCMode.All, highestVotedAction);
                }
            }

            if (battleStateHandler.highestVotedAction != 0)
            {
                switch ((BattleStateHandler.PlayerAction)battleStateHandler.highestVotedAction)
                {
                case BattleStateHandler.PlayerAction.FIREBALL:
                {
                    playerAction    = new BattleAction(0, BattleAction.DamageType.Fire);
                    attackBallImage = Object.Instantiate(battleStateHandler.fireballPrefab, new Vector2(), Quaternion.identity) as Image;
                    attackBallImage.transform.SetParent(battleStateHandler.canvas.transform, false);
                    break;
                }

                case BattleStateHandler.PlayerAction.COLDBALL:
                {
                    playerAction    = new BattleAction(12, BattleAction.DamageType.Cold);
                    attackBallImage = Object.Instantiate(battleStateHandler.coldballPrefab, new Vector2(), Quaternion.identity) as Image;
                    attackBallImage.transform.SetParent(battleStateHandler.canvas.transform, false);
                    break;
                }

                case BattleStateHandler.PlayerAction.DEFEND:
                {
                    playerAction    = new BattleAction(-11, BattleAction.DamageType.RegularType, BattleAction.Target.Self);
                    attackBallImage = Object.Instantiate(battleStateHandler.healBallPrefab, new Vector2(), Quaternion.identity) as Image;
                    attackBallImage.transform.SetParent(battleStateHandler.canvas.transform, false);
                    break;
                }

                default:
                    Debug.LogError("Unhandled player action");
                    break;
                }
                battleStateHandler.highestVotedAction = 0;
                actionPerformed = true;
            }
            else
            {
                playerAction    = new BattleAction(5, BattleAction.DamageType.RegularType, BattleAction.Target.Self);
                attackBallImage = Object.Instantiate(battleStateHandler.selfHitBallPrefab, new Vector2(), Quaternion.identity) as Image;
                attackBallImage.transform.SetParent(battleStateHandler.canvas.transform, false);
                actionPerformed = true;
            }
        }
Пример #9
0
        public IBattleState UpdateState(BattleStateHandler battleStateHandler)
        {
            if (battleStateHandler.player.IsDead())
            {
                return(new EndGameState(false));
            }

            bool animationDone = actionPerformed && attackBallImage == null;

            if (animationDone || actionTimeout <= 0)
            {
                if (playerAction != null)
                {
                    if (playerAction.GetTarget() == BattleAction.Target.Self)
                    {
                        if (playerAction.damage < 0)
                        {
                            battleStateHandler.battleTextField.text = string.Format("HEAL {0} Hit Points!", -playerAction.damage);
                        }
                        else
                        {
                            battleStateHandler.battleTextField.text = string.Format("JULIANA hurt herself in her confusion! Self inflicted {0} Hit Points!", playerAction.damage);
                        }
                        playerAction.Apply(battleStateHandler.player);
                    }
                    else if (playerAction.GetTarget() == BattleAction.Target.Enemy)
                    {
                        if (playerAction.type != BattleAction.DamageType.Failure)
                        {
                            playerAction.Apply(battleStateHandler.enemy);

                            string messageText = string.Format("{0} takes {1} {2} damage!", battleStateHandler.enemy.name, playerAction.damage, playerAction.type);

                            if ((playerAction.type == BattleAction.DamageType.Fire) && (battleStateHandler.currentFireMonsterState == BattleStateHandler.FireMonsterState.ATTACKING))
                            {
                                if (battleStateHandler.numberOfFireBallsHitBy < 1)
                                {
                                    messageText += "!  Fire Monster is uncomfortably hot!";
                                    ++battleStateHandler.numberOfFireBallsHitBy;
                                }
                                else
                                {
                                    messageText += "!  The Fire Monster is paralysed!!";
                                    battleStateHandler.numberOfFireBallsHitBy  = 0;
                                    battleStateHandler.currentFireMonsterState = BattleStateHandler.FireMonsterState.PARALYSED;
                                }
                            }
                            else if (battleStateHandler.currentFireMonsterState == BattleStateHandler.FireMonsterState.PARALYSED)
                            {
                                messageText += "!  Paralysis undone!!";
                                battleStateHandler.numberOfFireBallsHitBy  = 0;
                                battleStateHandler.currentFireMonsterState = BattleStateHandler.FireMonsterState.ATTACKING;
                            }

                            battleStateHandler.battleTextField.text = messageText;
                        }
                        else
                        {
                            battleStateHandler.battleTextField.text = string.Format("{0} tried to {1} but it failed!", "JULIANA", "DEMOCRACY", playerAction.type);
                        }
                    }
                }

                return(new EnemyActionState());
            }
            return(this);
        }