Наследование: MonoBehaviour
Пример #1
0
 private void CheckGameStatus()
 {
     CheckMateLabel.Visible = false;
     if (_game.IsGameOver() || _game.IsGameDraw())
     {
         TurnTimer.Stop();
         ChessBoard.Enabled        = false;
         BoardStateHistory.Enabled = false;
         Message.Location          = new Point(413, 150);
         if (_game.IsGameDraw())
         {
             Message.Text = drawMessage;
         }
         else
         {
             Message.Text = _currentPlayerName + winMessage;
         }
     }
     else
     {
         _currentPlayerTurn = _currentPlayerTurn == PlayerName.PlayerOne ? PlayerName.PlayerTwo : PlayerName.PlayerOne;
         _currentPlayerName = _currentPlayerTurn == PlayerName.PlayerOne ? playerOne : playerTwo;
         if (_game.IsCheck())
         {
             CheckMateLabel.Text    = _currentPlayerName + checkMateText;
             CheckMateLabel.Visible = true;
         }
     }
 }
Пример #2
0
    public override void BhvOnEnter()
    {
        //HeroHp = transform.Find("Anchor/HeroHP");
        BattleLoading = transform.Find("Anchor/Loading");
        DamageRoot    = transform.Find("Anchor/DamageRoot");

        var tranProfile = transform.Find("Anchor_BL/Profile");

        if (tranProfile != null)
        {
            Profiles[0] = tranProfile.GetComponent <BattleProfile>();
        }

        tranProfile = transform.Find("Anchor_BR/Profile");
        if (tranProfile != null)
        {
            Profiles[1] = tranProfile.GetComponent <BattleProfile>();
        }

        GoTurnTimer = transform.Find("Anchor/Timer").gameObject;
        if (GoTurnTimer != null)
        {
            TurnTime = GoTurnTimer.GetComponent <TurnTimer>();
        }
    }
Пример #3
0
        // ends the current turn
        private void EndTurn(TurnEndReason reason)
        {
            ConsoleManager.Instance.WriteLine($"Turn {TurnNumber} has ended, reason {reason}", MsgType.ServerInfo);

            controllers.ProcessTurn();
            TurnNumber++;
            TurnTimer.Restart();

            ConsoleManager.Instance.WriteLine($"Turn {TurnNumber} has begun", MsgType.ServerInfo);
            foreach (Player player in controllers.Player.GetAllPlayers())
            {
                Packet p = new Packet((int)PacketHeader.TurnData,
                                      TurnNumber,
                                      TurnTimeLimit,
                                      reason,
                                      player,
                                      controllers.City.GetAllCities(),
                                      controllers.Unit.GetAllUnits()
                                      );

                server.SendData(p, player.Connection);
            }

            //// TODO this is where we check for game over
            //Tuple<bool, Player, VictoryType> res = IsGameOver();
            //if (res.Item1)
            //    SendGameOver(res.Item2, res.Item3);
        }
Пример #4
0
        public bool Turn(Direction newDirection)
        {
            if (_currentTurnTimer != null)
            {
                _currentTurnTimer.Stop();
                _currentTurnTimer = null;
            }

            if (_currentMoveTimer != null)
            {
                _currentMoveTimer.Stop();
            }

            Direction oldFacing = _facing;

            if (SetFacing((int)newDirection % 2 != 0 ? newDirection - 1 : newDirection))
            {
                if (_speed != SpeedCode.Stop && _currentMoveTimer != null)
                {
                    _moving = IsDriven ? newDirection : (Direction)((int)_moving + (_facing - oldFacing)) & Server.Direction.Mask;
                    _currentMoveTimer.Start();
                }
                return(true);
            }

            if (_speed != SpeedCode.Stop && _currentMoveTimer != null) // if boat can't turn, restart movement if it was on moving
            {
                _currentMoveTimer.Start();
            }

            return(false);
        }
Пример #5
0
    private IEnumerator UpdateTimerText()
    {
        TurnTimer m_Timer = TurnTimer.Instance;

        if (m_Timer == null)
        {
            yield break;
        }

        while (true)
        {
            if (transform.parent.transform.parent.gameObject.GetComponent <TankController>().IsActive)
            {
                m_TimerText.text = "Timer: " + m_Timer.GetCurrentTime();

                if (m_Timer.FreezeTimer)
                {
                    m_TimerText.text += " (frozen)";
                }
            }
            else
            {
                m_TimerText.text = "Timer: ";
            }

            yield return(new WaitForSeconds(0.5f));
        }
    }
Пример #6
0
        private bool Turn(Direction newDirection)
        {
            if (m_TurnTimer != null)
            {
                m_TurnTimer.Stop();
                m_TurnTimer = null;
            }

            if (m_MoveTimer != null)
            {
                m_MoveTimer.Stop();
            }

            Direction oldFacing = m_Facing;

            if (SetFacing((int)newDirection % 2 != 0 ? newDirection - 1 : newDirection))
            {
                if (m_Speed != SpeedCode.Stop && m_MoveTimer != null)
                {
                    m_Moving = IsDriven ? newDirection : (Direction)((int)m_Moving + (m_Facing - oldFacing)) & Server.Direction.Mask;
                    m_MoveTimer.Start();
                }
                return(true);
            }

            if (m_Speed != SpeedCode.Stop && m_MoveTimer != null) // if boat can't turn, restart movement if it was on moving
            {
                m_MoveTimer.Start();
            }

            return(false);
        }
    public void Init()
    {
        ActiveCharacters   = new List <TurnCharacter>();
        TeamOneActiveChars = new List <TurnCharacter>();
        TeamTwoActiveChars = new List <TurnCharacter>();

        turnTimer = TurnTimer.Instance;
    }
Пример #8
0
 void Start()
 {
     movementAllowed  = false;
     tilesMoved       = 0;
     timer            = GameObject.FindGameObjectWithTag("TurnTimer").GetComponent <TurnTimer>();
     timer.moveBegin += StartMovement;
     pathFinding      = GetComponent <PathFinding>();
     movement         = new Queue <HexagonTile>();
 }
Пример #9
0
 public bool CurePetrify(Combatant source)
 {
     Petrify = false;
     if (!(Sleep || Stop || Paralysed || Imprisoned))
     {
         TurnTimer.Reset();
     }
     return(true);
 }
Пример #10
0
        private void GameLoaded(StateType state)
        {
            StateManager.GameStateChanged -= GameLoaded;

            InitPlayers();
            LoadGameData();
            SelectedUnit = ActivePlayer.UnitInTurn;
            TurnTimer.StartTimer();
        }
Пример #11
0
        protected override void Kill()
        {
            _c.HP = 0;

            CureAll(this);
            TurnTimer.Reset();
            PauseTimers();

            // TODO: final attack
        }
Пример #12
0
 public bool CureParalyzed(Combatant source)
 {
     Paralysed        = false;
     ParalyzedTimeEnd = -1;
     if (!(Sleep || Stop || Petrify || Imprisoned))
     {
         TurnTimer.Unpause();
     }
     return(true);
 }
Пример #13
0
 public override void Update(float frameDelta)
 {
     if (gameSession.isServer)
     {
         TurnTimer timer = GameUtils.GetTurnTimer();
         if (timer.IsTimeUp())
         {
             gameSession.GetWaitingOnPlayer().ServerForceConfirmation();
         }
     }
 }
Пример #14
0
 private void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Пример #15
0
        public bool CureSleep(Combatant source)
        {
            SleepTimeEnd = -1;

            if (!(Stop || Petrify || Paralysed || Imprisoned))
            {
                TurnTimer.Unpause();
            }

            return(true);
        }
Пример #16
0
        protected override void Kill()
        {
            _hp    = 0;
            _death = true;

            CureAll(this);
            TurnTimer.Reset();
            PauseTimers();

            RunAICounterDeath();
        }
Пример #17
0
 TurnTimer()
 {
     //save time instead of searching for the game controller
     //check if the instance is not null, we are creating more than one instance, warn us
     if (instance != null)
     {
         Debug.LogError("There's an instance already created, click on the next error to check it", gameObject);
         Debug.LogError("Original TurnTimer instance is", instance.gameObject);
         return;
     }
     instance = this;
 }
Пример #18
0
        protected virtual bool BeginTurn(Direction newDirection)
        {
            if (m_TurnTimer != null)
            {
                m_TurnTimer.Stop();
            }

            m_TurnTimer = new TurnTimer(this, newDirection);
            m_TurnTimer.Start();

            return(true);
        }
Пример #19
0
        private void RobotTurn(ref bool MyTurn)
        {
            if (MyTurn == false)
            {
                Random random = new Random();

                labelWhosTurn.Text = "ХОД РОБОТА"; labelWhosTurn.ForeColor = Color.Red;
                Cursor             = Cursors.WaitCursor;
                TurnTimer.Interval = random.Next(5000, 7000);
                TurnTimer.Start();
            }
        }
Пример #20
0
        protected virtual bool BeginTurn(Direction newDirection)
        {
            if (_currentTurnTimer != null)
            {
                _currentTurnTimer.Stop();
            }

            _currentTurnTimer = new TurnTimer(this, newDirection);
            _currentTurnTimer.Start();

            return(true);
        }
 private void Awake()
 {
     s_instance   = this;
     this.m_spell = base.GetComponent <Spell>();
     this.m_spell.AddStateStartedCallback(new Spell.StateStartedCallback(this.OnSpellStateStarted));
     if (GameState.Get() != null)
     {
         GameState.Get().RegisterCurrentPlayerChangedListener(new GameState.CurrentPlayerChangedCallback(this.OnCurrentPlayerChanged));
         GameState.Get().RegisterTurnTimerUpdateListener(new GameState.TurnTimerUpdateCallback(this.OnTurnTimerUpdate));
         GameState.Get().RegisterGameOverListener(new GameState.GameOverCallback(this.OnGameOver), null);
     }
 }
Пример #22
0
 public void ChangeTurn()
 {
     _playerIndex++;
     if (_playerIndex >= AllPlayers.Length)
     {
         _playerIndex = 0;
     }
     ActivePlayer.StartTurn();
     TurnTimer.Stop();
     TurnTimer.Reset();
     TurnTimer.StartTimer();
     OnTurnChanged();
 }
Пример #23
0
    public override void OnExit()
    {
        if (gameSession.isServer)
        {
            gameSession.ResetPriorityPasses();

            TurnTimer turnTimer = GameUtils.GetTurnTimer();
            turnTimer.ResetTimer(true);
            turnTimer.StoreTimer();

            activePlayer = null;
        }
    }
Пример #24
0
 public bool CureStop(Combatant source)
 {
     Stop = false;
     if (!Imprisoned)
     {
         UnpauseTimers();
         if (Sleep || Petrify || Paralysed)
         {
             TurnTimer.Pause();
         }
     }
     return(true);
 }
Пример #25
0
        public void StartPexeso(int row, int columns)
        {
            CreateCardsForGame(row, columns);
            Score = 0;

            RoundTimer.Start();
            ChoseSecondCardTimer.Start();
            TurnTimer.Start();

            RoundStopWatch.Start();
            TurnStopWatch.Start();
            //ChoseSecondCardStopwatch.Start();
        }
Пример #26
0
    private void Die()
    {
        TurnCharacter dataChar = this.gameObject.GetComponent <UnityCharacterTurnInfo>().DataCharacter;

        // If the character dying is the active character, in case they died without firing, set the turn time to 7 seconds
        if (dataChar.CurrentState == CharacterState.active)
        {
            TurnTimer t = TurnTimer.Instance;

            t.SetTurnTime(7f);
        }

        dataChar.Die(); // At the end of the turn, the character will be set inactive since its state is now "dead"
    }
Пример #27
0
        }   // Timerları yavaşlatma işlemini gerçekleştiren buton

        private void turnTimerControl_Click(object sender, EventArgs e)
        {
            if (btnPlayStop.AccessibleName == "1")
            {
                TurnTimer.Stop();
                btnPlayStop.AccessibleName = "2";
                btnPlayStop.Image          = Properties.Resources.playButton;
            }
            else
            {
                TurnTimer.Start();
                btnPlayStop.AccessibleName = "1";
                btnPlayStop.Image          = Properties.Resources.pauseButton;
            }
        }  // Timerları durdurup , başlatma işlemini gerçekleştiren buton
Пример #28
0
        // parses a packet with the header TurnData
        private void ParseTurnData(Packet p)
        {
            int i = 0;

            TurnNumber    = (int)p.Items[i++];
            TurnTimeLimit = (int)p.Items[i++];
            TurnEndReason reason = (TurnEndReason)p.Items[i++];

            Player   = (Player)p.Items[i++];
            Cities   = (List <City>)p.Items[i++];
            AllUnits = (List <UnitInstance>)p.Items[i++];
            UpdateCache();
            ConsoleManager.Instance.WriteLine($"Recieved data for turn {TurnNumber}");
            TurnState = TurnState.Begin;
            TurnTimer.Restart();
        }
Пример #29
0
 // loop thread: runs processes that can't be event driven
 private void UpdateLoop()
 {
     TurnTimer.Start();
     while (Running)
     {
         if (TurnTimer.ElapsedMilliseconds > TurnTimeLimit)
         {
             foreach (Player player in controllers.Player.GetAllPlayers())
             {
                 player.EndedTurn = true;
             }
             EndTurn(TurnEndReason.TimeOut);
             TurnTimer.Restart();
         }
     }
 }
Пример #30
0
        public bool InflictSleep(Combatant source)
        {
            if (Immune(Status.Sleep))
            {
                return(false);
            }
            if (Sleep || Petrify || Peerless || Resist)
            {
                return(false);
            }

            CureManipulate(source);

            SleepTimeEnd = V_Timer.ElapsedUnits;
            TurnTimer.Pause();
            return(true);
        }
Пример #31
0
    void Start()
    {
        totalCritters = 0;

        critterGenerator = FindObjectOfType<CritterGenerator>();
        turnTimer = FindObjectOfType<TurnTimer>();
        uiControl = FindObjectOfType<UIController>();
        pUnlocksControl = FindObjectOfType<PlayerUnlocksController>();

        PopulateStartSpriteList();

        //Generates game environment
        gameState = state.LOAD;
        GenerateMap();
        GenerateCritters();

        //Starts Game for player
        if(gameState == state.START){
            uiControl.ActivateGameStartPanel();
        }
    }
Пример #32
0
    void Awake()
    {
        backgroundSprites = IconController.GetAllHexBackgrounds();
        player = FindObjectOfType<Player>();
        turnTimer = FindObjectOfType<TurnTimer>();
        iconControl = FindObjectOfType<IconController>();
        hud = GetComponentInChildren<HexHUD>();
        Sprites = GetComponentsInChildren<SpriteRenderer>();
        happyMeter = GetComponentInChildren<HappinessMeter>();
        hudItems = GetComponentsInChildren<HexHudItem>();

        Main = FindObjectOfType<Camera>();
        Transform parentTransform = FindObjectOfType<MapController>().transform;
        transform.SetParent(parentTransform);

        if(!restrictionsPanel){
            restrictionsPanel = GetComponentInChildren<HexRestrictions>();
        }

        EnableHex();

        Sprites[0].material.color = new Color32(140, 140 , 140, 220);
        Sprites[1].color = SetTempColors();
        Sprites[2].sprite = SetBiomeSprite();

        localPlantFood = DefineMaxPlantFood();
        insectFood = DefineMaxInsectFood();
        fishFood = DefineMaxFishFood();
        meatHealth = .99f;

        if(localType == BiomeType.SALTWATER){
            fishFood *= 2;
        }
        else if(localType == BiomeType.FRESHWATER)
        {
            fishFood *= 1.5f;
        }

        CalculateFishHealth();
        CalculateInsectHealth();
        GrowFood();
        meatHealth = CalculateMeatHealth();
        CalculateWasteFood(previousExcessMeatFood);

        //print ("Hex# " + number + "  - Plants: " + localPlantFood + "  - Insects: " + insectFood + "  - Fish: " + fishFood + "\r\n");
    }
Пример #33
0
    //Declarations + zeroing out critter poulations and energy levels
    void Awake()
    {
        gameControl = FindObjectOfType<GameController>();
        turnTimer = FindObjectOfType<TurnTimer>();
        player = FindObjectOfType<Player>();
        evoList = GetComponent<EvolutionList>();
        SplinterXP = 0;

        transform.parent = GameObject.FindGameObjectWithTag("Critters").transform;

        completedPhases = 0;
        tokenDensity = (200 / gameControl.tokenDensity) * size;
        breedSeason = GameController.breedSeason;

        SetBreedRate(GameController.breedRate);
        UpdateStats();

        evoButton = FindObjectOfType<EvolutionButton>();
        migrateButton = FindObjectOfType<MigrateAnimControl>();
    }