Exemple #1
0
        public void nextFrame()
        {
            phase = PHASE.PROCESSING_FRAME;
            foreach (int id in entities.Keys)
            {
                Entity child = entities[id];
                if (child.owned)
                {
                    if (child is EllipseEntity)
                    {
                        EllipseEntity ellipseEntity = (EllipseEntity)child;
                        ellipseEntity.testCollision(entities.Values.ToList()); // TODO: using ToList may be inefficient
                    }
                    else if (child is FreeEntity)
                    {
                        FreeEntity freeEntity = (FreeEntity)child;
                        freeEntity.testCollision(entities.Values.ToList()); // TODO: using ToList may be inefficient
                    }
                    // Do not do collisions for SliderEntities

                }
            }
            // NB: Phase changes trigger actions, do not remove the "un-necessary" phase change
            phase = PHASE.FINISHED_FRAME;
            phase = PHASE.READY_FOR_CHANGES;
        }
        public MainWindow()
        {
            /*
             * 初期化関連
             */

            phase = PHASE.INITIALIZING;

            switch(controllerDevice)
            {
                case CONTROLLER_DEVICE.KINECT:
                    k = new Kinect(this);
                    break;
                case CONTROLLER_DEVICE.GAMEPAD:
                    // ゲームパッドの初期化
                    break;
            }

            InitializeComponent();

            switch(controllerDevice)
            {
                case CONTROLLER_DEVICE.KINECT:
                    k.start();
                    break;
                case CONTROLLER_DEVICE.GAMEPAD:
                    // ゲームパッドの開始
                    break;
            }

            /*
             * テスト
             */

            FallingRect f = new FallingRect(this, 50);
            f.X = 50;
            f.Y = 20;
            fallingRects = new FallingRect[] { f };
            f.drawForward();

            phase = PHASE.PLAYING;

            /*
             * タイマーにイベントを登録して0.05秒ごとにイベントを実行する
             */

            dispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal);
            dispatcherTimer.Interval = new TimeSpan(500000);
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Start();
        }
 public void NextPhase()
 {
     switch (Phase)
     {
         case PHASE.ONE:
             m_anim.SetTrigger("Mouth Attack");
             Phase = PHASE.TWO;
             break;
         case PHASE.TWO:
             StartCoroutine("DeathSequence");
             break;
         default:
             break;
     }
 }
	void PhaseOne(float angleToPlayer)
	{
		if (angleToPlayer > 5.0f || (gameObject.transform.position - player.transform.position).magnitude > StoppingDistance)
		{
			inRange = false;
		}
		else
		{
			inRange = true;
			resetTimer = 0.0f;
			agent.Stop();
		}

		if (inRange || currentAction.isBehaving())
		{
			if (currentAction.Execute() == COMPLETION_STATE.COMPLETE)
			{
				// Increment the action
				nextAction++;

				if (nextAction >= phaseOne.Count)
					nextAction = 0;

				currentAction = phaseOne[nextAction];
			}
		}

		else
		{
			resetTimer += Time.deltaTime;
			if (resetTimer > resetTimerMax)
			{
				resetTimer = 0.0f;
				currentAction = phaseOne[0];
				nextAction = 0;
			}
			SeekPlayer();
		}

		if (puppet.curTallys <= 2)
		{
			if (minion != null)
			{
				GameObject thisGuy = (GameObject)(GameObject.Instantiate(minion, minionSpawnLocation.transform.position, Quaternion.identity));
				minionPuppet = thisGuy.GetComponent<PuppetScript>();
				minionSummoned = true;
				agent.SetDestination(retreatPoint.transform.position);
				puppet.ChangeState(PuppetScript.State.MOVING);
				animation.Play("Walk Forward");
			}
			phase = PHASE.TWO;
		}
	}
        /*
        ====================================================================
        Begin turn of next player. Therefore select next player or use
        'forced_player' if not NULL (then the next is the one after
        'forced_player').
        If 'skip_unit_prep' is set scen_prep_unit() is not called.
        ====================================================================
        */
        public static string engine_begin_turn(Player forced_player, bool skip_unit_prep)
        {
            char[] text = new char[400];
            int new_turn = 0;
            Player player = null;
            #if TODO
            /* clear various stuff that may be still set from last turn */
            group_set_active( gui.confirm, ID_OK, 1 );
            engine_hide_unit_menu();
            engine_hide_game_menu();
            #endif
            /* clear undo */
            engine_clear_backup();
            /* clear hideous clicks */
            #if TODO
            if ( !deploy_turn && cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_HUMAN )
                event_wait_until_no_input();
            #endif

            /* get player */
            if (forced_player == null)
            {
                /* next player and turn */
                player = Player.players_get_next(out new_turn);
                if (new_turn != 0)
                {
                    Scenario.turn++;
                }
                if (Scenario.turn == Scenario.scen_info.turn_limit)
                {
                    /* use else condition as Scenario result */
                    /* and take a final look */
                    Scenario.scen_check_result(true);
                    blind_cpu_turn = false;
                    engine_show_final_message();
                    draw_map = true;
            #if TODO
                    image_hide(gui.cursors, 0);
                    gui_set_cursor(CURSOR_STD);
            #endif
                    engine_select_player(null, skip_unit_prep);
                    engine_set_status(STATUS.STATUS_NONE);
                    phase = PHASE.PHASE_NONE;
                    return "";
                }
                else
                {
                    Scenario.cur_weather = Scenario.scen_get_weather();
                    engine_select_player(player, skip_unit_prep);
                }
            }

            else
            {
                engine_select_player(forced_player, skip_unit_prep);
                Player.players_set_current(Player.player_get_index(forced_player));
            }
            #if DEBUG_CAMPAIGN
            if ( scen_check_result(0) ) {
                blind_cpu_turn = 0;
                engine_show_final_message();
                draw_map = 1;
                image_hide( gui.cursors, 0 );
                gui_set_cursor( CURSOR_STD );
                engine_select_player( 0, skip_unit_prep );
                engine_set_status( STATUS_NONE );
                phase = PHASE_NONE;
                end_scen = 1;
                return;
            }
            #endif

            /* init ai turn if any */
            if (cur_player != null && cur_player.ctrl == PLAYERCONTROL.PLAYER_CTRL_CPU)
                cur_player.ai_init();
            /* turn info */
            string scen_info = engine_show_turn_info();
            engine_set_status(deploy_turn ? STATUS.STATUS_DEPLOY : STATUS.STATUS_NONE);
            phase = PHASE.PHASE_NONE;
            /* update screen */
            if (cur_ctrl != PLAYERCONTROL.PLAYER_CTRL_CPU || Config.show_cpu_turn)
            {
            #if TODO
                if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_CPU)
                    engine_update_info(0, 0, 0);
                else
                {
                    image_hide(gui.cursors, 0);
                }
                engine_draw_map();
            #endif
                blind_cpu_turn = false;
            }
            else
            {
            #if TODO
                engine_update_info(0, 0, 0);
                draw_map = false;
                FULL_DEST(sdl.screen);
                fill_surf(0x0);
                gui.font_turn_info.align = ALIGN_X_CENTER | ALIGN_Y_CENTER;
                sprintf(text, tr("CPU thinks..."));
                write_text(gui.font_turn_info, sdl.screen, sdl.screen.w >> 1, sdl.screen.h >> 1, text, OPAQUE);
                sprintf(text, tr("( Enable option 'Show Cpu Turn' if you want to see what it is doing. )"));
                write_text(gui.font_turn_info, sdl.screen, sdl.screen.w >> 1, (sdl.screen.h >> 1) + 20, text, OPAQUE);
                refresh_screen(0, 0, 0, 0);
            #endif
                blind_cpu_turn = true;
            }
            if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_CPU)
            {
                while (!cur_player.ai_run()) ;
            }
            return scen_info;
        }
 public static void EndCombat()
 {
     #if WITH_SOUND
     audio_fade_out( 2, 1500 ); /* explosion sound channel */
     #endif
     /* costs one fuel point for attacker */
     if (cur_unit != null && cur_unit.CheckFuelUsage() && cur_unit.cur_fuel > 0)
         cur_unit.cur_fuel--;
     /* update the visible units list */
     map.map_get_vis_units();
     map.map_set_vis_infl_mask();
     /* reselect unit */
     if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_HUMAN)
         engine_select_unit(cur_unit);
     /* status */
     engine_set_status(STATUS.STATUS_NONE);
     #if TODO
     label_hide(gui.label2, 1);
     #endif
     phase = PHASE.PHASE_NONE;
     /* allow new human/cpu input */
     if (!blind_cpu_turn)
     {
         if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_HUMAN)
         {
     #if TODO
             image_hide(gui.cursors, 0);
             gui_set_cursor(CURSOR_STD);
     #endif
         }
         draw_map = true;
     }
     AI_Enemy.Action.action_queue(EngineActionsTypes.ACTION_NONE);
     //stateMachine.Send(EngineActionsTypes.ACTION_NONE);
     //remove stateMachine.scheduler.Stop();
 }
 public static void CheckLastMove()
 {
     /* insert unit */
     //map.map_insert_unit(move_unit);
     /* capture flag if there is one */
     /* NOTE: only do it for AI. For the human player, it will
      * be done on deselecting the current unit to resemble
      * original Panzer General behaviour
      */
     if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_CPU)
     {
         if (engine_capture_flag(move_unit))
         {
             /* CHECK IF SCENARIO IS FINISHED */
             if (Scenario.scen_check_result(false))
             {
                 engine_finish_scenario();
                 return;
             }
         }
     }
     /* add influence */
     if (!Player.player_is_ally(move_unit.player, cur_player))
         map.map_add_unit_infl(move_unit);
     /* update the visible units list */
     map.map_get_vis_units();
     map.map_set_vis_infl_mask();
     /* next phase */
     phase = PHASE.PHASE_END_MOVE;
     AI_Enemy.Action.action_queue(EngineActionsTypes.ACTION_END_MOVE);
     //stateMachine.Send(EngineActionsTypes.ACTION_END_MOVE);
 }
Exemple #8
0
    public void ChangePhase(PHASE phase)
    {
        turnPhase = phase ;

        //各playerのunitFieldに対してphaseの効果を促すSendMessage()を送る

        setPhase[(int)turnPhase]() ;
    }
Exemple #9
0
 public void PlayPhase(Player _player)
 {
     if(TurnCounter != Players.IndexOf(_player) && PhaseCounter != PHASE.PLAY){
         return;
     }
     //discard selected card
     _player.Discard.Add(_player.LastDiscarded);
     _player.LastDiscarded = _player.Hand[_player.SelectedCard];
     LastPlayed = _player.Hand[_player.SelectedCard];
     _player.Hand.RemoveAt(_player.SelectedCard);
     //inc PhaseCounter
     PhaseCounter = PHASE.PEG;
 }
Exemple #10
0
    public void NewGame(/*default is 2v2*/)
    {
        TurnCounter = 0;
        PhaseCounter = PHASE.DRAW;

        TableBoard = new Board(4);

        TableDeck = new Deck(2);
        TableDeck.Shuffle();

        Players = new List<Player>();
        //needs dynamic logic for player number and team number
        Players.Add(new Player("Player One", 1));
        Players.Add(new Player("Player Two", 2));
        Players.Add(new Player("Player Three", 1));
        Players.Add(new Player("Player Four", 2));

        Deal();

        //print players cards to test
        /*foreach(Player _player in Players){
            Debug.Log("" + _player.Name);
            foreach(Card _card in _player.Hand){
                Debug.Log(_card.FaceValue());
            }
        }*/
    }
Exemple #11
0
 /// <summary>
 /// We did not get some turns, force it.
 /// </summary>
 public void TurnStartTimout()
 {
     foreach (Player player in Players.Where(player => player.WaitingForReply != Player.COMM_MODE.READY))
     {
         framework.mainWindow.StatusMessage(string.Format("Player {0} did not provide a turn", player.Name));
         PlayerTurn(player, new List<Card>(), false);
     }
     phaseOn = PHASE.MOVE_ROBOT;
 }
Exemple #12
0
        public void Tick()
        {
            // ok, time to execute this phase.
            switch (phaseOn)
            {
                // if phase 0, start the turn.
                case PHASE.GET_TURN:
                    TurnOn++;
                    ExecuteStartTurn();
                    framework.mainWindow.UpdatePlayers();
                    break;

                case PHASE.MOVE_ROBOT:
                    framework.mainWindow.TurnNumber(TurnOn, cardOn + 1);
                    ExecuteMoveRobot();
                    phaseOn = PHASE.MOVE_BOARD;
                    break;

                case PHASE.MOVE_BOARD:
                    ExecuteMoveBoard();
                    phaseOn = PHASE.FIRE;
                    break;

                case PHASE.FIRE:
                    ExecuteFire();
                    phaseOn = PHASE.FLAG_ARCHIVE;
                    framework.mainWindow.UpdatePlayers();
                    break;

                case PHASE.FLAG_ARCHIVE:
                    ExecuteFlagAndArchive();
                    if (! StepMode)
                        framework.laserBeams.Clear();
                    cardOn++;

                    // if last phase, end the turn.
                    if (cardOn >= Framework.NUM_PHASES)
                    {
                        ExecuteEndTurn();
                        if (StepMode)
                            framework.Pause();
                    }
                    else
                        phaseOn = PHASE.MOVE_ROBOT;
                    framework.mainWindow.UpdatePlayers();
                    break;
            }
        }
Exemple #13
0
 public void PlayerSetArchive(Player player, BoardLocation location)
 {
     player.Robot.Location = location;
     if (!Players.Any(pl => pl.Robot.Location.IsNull && pl.TcpGuid != null))
         phaseOn = PHASE.GET_TURN;
 }
Exemple #14
0
 public void Initialize()
 {
     cardOn = 0;
     TurnOn = 0;
     phaseOn = PHASE.GET_TURN;
     MainMap = GameMap.CreateMap();
     foreach (Player plyr in Players)
         plyr.Reset();
 }
Exemple #15
0
        /// <summary>
        /// get the cards for all players
        /// </summary>
        public void ExecuteStartTurn()
        {
            // set to waiting phase
            foreach (Player player in Players)
                player.WaitingForReply = Player.COMM_MODE.WAITING_FOR_TURN;
            phaseOn = PHASE.WAITING_ON_PLAYERS;
            ValidateData();

            #if DEBUG
            Trace.WriteLine(string.Format("starting turn {0}", TurnOn));
            foreach (Player player in Players)
                Trace.WriteLine(string.Format("     Player {0}, mode {1}, Lives {2}, Damage {3}, Mode {4}, Location {5}",
                                              player.Name, player.Mode, player.Lives, player.Damage, player.Mode,
                                              player.Robot.Location));
            #endif

            // create 40 cards.
            // unique priorities across all
            // ROBOT_MOVE num of cards in enum order are 6, 18, 12, 6, 18, 18, 6
            List<int> priorityNums = CreatePriorityNumbers();
            List<Card> cards = new List<Card>();
            cards.AddRange(priorityNums.Take(6).Select(priority => new Card(Card.ROBOT_MOVE.BACKWARD_ONE, priority)));
            cards.AddRange(priorityNums.Skip(6).Take(18).Select(priority => new Card(Card.ROBOT_MOVE.FORWARD_ONE, priority)));
            cards.AddRange(priorityNums.Skip(6 + 18).Take(12).Select(priority => new Card(Card.ROBOT_MOVE.FORWARD_TWO, priority)));
            cards.AddRange(priorityNums.Skip(6 + 18 + 12).Take(6).Select(priority => new Card(Card.ROBOT_MOVE.FORWARD_THREE, priority)));
            cards.AddRange(priorityNums.Skip(6 + 18 + 12 + 6).Take(18).Select(priority => new Card(Card.ROBOT_MOVE.ROTATE_LEFT, priority)));
            cards.AddRange(priorityNums.Skip(6 + 18 + 12 + 6 + 18).Take(18).Select(priority => new Card(Card.ROBOT_MOVE.ROTATE_RIGHT, priority)));
            cards.AddRange(priorityNums.Skip(6 + 18 + 12 + 6 + 18 + 18).Take(6).Select(priority => new Card(Card.ROBOT_MOVE.ROTATE_UTURN, priority)));

            Trace.WriteLine("Turns:");
            foreach (Player player in Players)
            {
                if (player.Mode == Player.MODE.DEAD)
                {
                    player.Cards = new List<Card>();
                    player.WaitingForReply = Player.COMM_MODE.READY;
                    continue;
                }
                // if powered down keep old cards
                if (player.Mode == Player.MODE.POWER_DOWN)
                {
                    player.WaitingForReply = Player.COMM_MODE.READY;
                    continue;
                }

                // grab the players dealt cards
                int numCards = 9 - player.Damage;
                List<Card> dealtCards = new List<Card>();
                while (numCards-- > 0)
                {
                    int index = rand.Next(cards.Count);
                    dealtCards.Add(cards[index]);
                    cards.RemoveAt(index);
                }
                player.ServerDealtCards = dealtCards;
                framework.RequestTurn(MainMap, player, Players, dealtCards);
            }

            // start timer for 1 second
            ValidateData();
            framework.WaitingForTurns();
            if (!Players.Any(pl => pl.WaitingForReply != Player.COMM_MODE.READY))
                phaseOn = PHASE.MOVE_ROBOT;
        }
Exemple #16
0
 // if all done - ready to start
 public void CheckAllTurnsIn()
 {
     if (Players.Any(pl => pl.WaitingForReply != Player.COMM_MODE.READY))
         return;
     framework.ReceivedAllTurns();
     phaseOn = PHASE.MOVE_ROBOT;
 }
    private void GameMain()
    {
        float randNum = Random.Range(0.0f, 100.0f);
        int   rNum    = Random.Range(0, 2);

        //ミサイルの出現抽選
        if (!isCreateMissile)
        {
            if (randNum < missileCreatePro)
            {
                GameObject item = Instantiate(missilePrefab, transform.position, missilePrefab.gameObject.transform.rotation);
                item.GetComponent <ItemMissile>().RandSet(rNum);
                torpedoIcons[rNum].gameObject.SetActive(true);
                Invoke("HideIcon", 1f);

                isCreateMissile = true;
            }
        }

        //生成時間の最大値を超えた
        if (++frameCnt > createMissileTimeMax)
        {
            //ミサイルが生成されていなければ生成
            if (!isCreateMissile)
            {
                GameObject item = Instantiate(missilePrefab, transform.position, missilePrefab.gameObject.transform.rotation);
                item.GetComponent <ItemMissile>().RandSet(rNum);
                torpedoIcons[rNum].gameObject.SetActive(true);
                Invoke("HideIcon", 1f);
            }

            frameCnt = 0;

            isCreateMissile = false;
        }

        //得点の更新
        submarinePoint = submarineController.enterPoint;

        shipPoint = trashCount.shipPoints;

        //ゲージの更新
        //船ゲージの取得
        GameObject shipGauge = GameObject.Find("ShipGauge").gameObject;

        //潜水艦ゲージの取得
        GameObject submarineGauge = GameObject.Find("SubmarineGauge").gameObject;

        //全体の得点を求める
        float totalPoint = shipPoint + submarinePoint;

        //トータルポイントが0でない時にゲージを更新する
        if (totalPoint > 0)
        {
            //全体の得点から船と潜水艦の得点の割合を求める
            float shipPointRait      = (float)shipPoint / totalPoint;
            float submarinePointRait = (float)submarinePoint / totalPoint;

            //割合に応じたゲージの切り出し位置にする
            //船側ゲージの更新
            shipGauge.GetComponent <RectTransform>().sizeDelta = new Vector2(50.0f, 270.0f * shipPointRait);

            //潜水艦側ゲージの更新
            submarineGauge.GetComponent <RectTransform>().sizeDelta = new Vector2(50.0f, 270.0f * submarinePointRait);
        }

        //制限時間の表示
        gameTimeText.text = gameTime.ToString("f1");

        gameTime -= Time.deltaTime;

        if (gameTime < 0)
        {
            gameTimeText.color = new Color(255.0f, 0.0f, 0.0f, 0.0f);

            gameTime = 0.0f;

            gamePhase = PHASE.PHASE_FINISH;
        }
        else if (gameTime < 10)
        {
            gameTimeText.color = new Color(255.0f, 0.0f, 0.0f, 0.5f);
        }
        else if (gameTime < gaugeDeleteTime)
        {
            shipGauge.GetComponent <Image>().color      = new Color(255.0f, 0.0f, 0.0f, 0.0f);
            submarineGauge.GetComponent <Image>().color = new Color(0.0f, 0.0f, 255.0f, 0.0f);

            GameObject shipIcon = GameObject.Find("ShipIcon").gameObject;
            shipIcon.GetComponent <Image>().color = new Color(255.0f, 255.0f, 255.0f, 0.0f);

            GameObject submarineIcon = GameObject.Find("SubmarineIcon").gameObject;
            submarineIcon.GetComponent <Image>().color = new Color(255.0f, 255.0f, 255.0f, 0.0f);
        }
        else
        {
            gameTimeText.color = new Color(255.0f, 255.0f, 255.0f, 0.3f);
        }
    }
Exemple #18
0
    // This function is used to check if there are still conflicts in the queue and set current phase to the correct phase
    void Conflict()
    {
        tCursor.ClearTargets();
        // Check if there is a conflict in the queue
        conflictInQueue = -1;
        for (int i = 4; i > -1; i--)
        {
            if (combatQueue[i].action == "None" &&
                combatQueue [i].tag == "Player" &&
                combatQueue [i + 1].tag == "Player" &&
                combatQueue [i].Stamina == combatQueue [i + 1].Stamina)
            {
                conflictInQueue = i;
            }
        }

        // Disable all enemy buttons
        foreach (Button B in enemySelect)
        {
            B.enabled = false;
        }
        // Get the position of the first player without an action
        int firstAction = -1;

        for (int i = 5; i > -1; i--)
        {
            if (combatQueue [i].action == "None" &&
                !combatQueue[i].dead)
            {
                firstAction = i;
            }
        }
        // This block will run when findstatus can work properly
        if (firstAction != -1 &&
            combatQueue[firstAction].findStatus("stun") != -1)
        {
            combatQueue[firstAction].action      = "Wait";
            combatQueue [firstAction].actionType = "None";
            combatQueue [firstAction - 1].CallTell();
            return;
        }


        // If there is a conflict in the queue but someone else has priority
        if (conflictInQueue != -1 && firstAction >= conflictInQueue)
        {
            currentPhase = PHASE.SELECT;
        }
        else
        {
            // If there is a character without an action
            if (firstAction != -1)
            {
                if (!combatQueue[firstAction].dead)
                {
                    if (combatQueue [firstAction].tag == "Player")
                    {
                        currentPhase = PHASE.ACTION;
                    }
                    else
                    {
                        // This allows the player to control enemy actions for now
                        currentPhase = PHASE.ACTION;
                        //EnemyTurn (firstAction);
                    }
                }
                else
                {
                    // All downed character are given the rest action
                    for (int i = firstAction; i < 6; i++)
                    {
                        combatQueue [i].action     = "Rest";
                        combatQueue [i].actionType = "Utility";
                        for (int j = 0; j < combatQueue[i].Target.Length; j++)
                        {
                            combatQueue [i].Target[j] = combatQueue [i];
                        }
                    }
                }
            }
        }
        // If there are no characters without actions
        if (firstAction == -1)
        {
            // This block does a stable sort to move the players who are catching to the front of the queue
            int j = 0;
            for (int i = 0; i < 6; i++)
            {
                int k = 0;
                if (combatQueue[i].action == "Catch")
                {
                    Character temp = combatQueue [i];
                    while (i - k > j)
                    {
                        combatQueue [i - k] = combatQueue [i - k - 1];
                        k++;
                    }
                    combatQueue [j] = temp;
                    j++;
                }
            }
            // This is a brute force way to make sure the last character's tell is shown, even if they aren't last in the queue
            foreach (Character C in combatQueue)
            {
                C.CallTell();
            }
            currentPhase = PHASE.EXECUTE;
            Execute();
        }
        if (firstAction != -1)
        {
            currentCharacter = firstAction;
            if (firstAction > 0)
            {
                combatQueue [firstAction - 1].CallTell();
            }
        }
    }
Exemple #19
0
 public void MovePhase(Player _player)
 {
     if(TurnCounter != Players.IndexOf(_player) && PhaseCounter != PHASE.MOVE){
         return;
     }
     //needs logic for which peg is moved first.
     if(LastPlayed.Rank == RANK.Ten || LastPlayed.Rank == RANK.Nine || LastPlayed.Rank == RANK.Seven){
         if(TestPegMove(FirstPeg, MoveToLocationFirst, MoveToDistanceFirst)){
             FirstPeg.Location = MoveToLocationFirst;
             FirstPeg.Distance = MoveToDistanceFirst;
         }
         if(TestPegMove(SecondPeg, MoveToLocationSecond, MoveToDistanceSecond)){
             SecondPeg.Location = MoveToLocationSecond;
             SecondPeg.Distance = MoveToDistanceSecond;
         }
     }else{
         if(TestPegMove(FirstPeg, MoveToLocationFirst, MoveToDistanceFirst)){
             FirstPeg.Location = MoveToLocationFirst;
             FirstPeg.Distance = MoveToDistanceFirst;
         }
     }
     //move logic
     //if(!TestPegMovement()){
     //return;
     //}
     PhaseCounter = PHASE.END;
 }
Exemple #20
0
        // end of turn - power up/down, un-destroy, repair
        private void ExecuteEndTurn()
        {
            phaseOn = PHASE.GET_TURN;

            foreach (Player playerOn in Players)
            {
                ValidateData();
                if (playerOn.Mode == Player.MODE.DEAD)
                    continue;

                // power down - after all moves, was not killed
                if ((playerOn.Mode == Player.MODE.ACTIVE) && (playerOn.PowerMode == Player.POWER_MODE.ANNOUNCED))
                {
                    playerOn.PowerDown();
                    Trace.WriteLine(string.Format("power down - Player: {0}, damage {1}", playerOn.Name, playerOn.Damage));
                }
                else
                    // power up - still alive
                    if (playerOn.PowerMode == Player.POWER_MODE.DOWN)
                    {
                        if (--playerOn.PowerDownTurnsRemaining > 0)
                            continue;
                        playerOn.PowerUp();
                        Trace.WriteLine(string.Format("power up - Player: {0}, damage {1}", playerOn.Name, playerOn.Damage));
                        if (playerOn.Mode == Player.MODE.DEAD)
                            continue;
                    }

                // we bring the robot back in at the end of the turn if it was destroyed.
                if (playerOn.Mode == Player.MODE.DESTROYED)
                {
                    // is the archive available?
                    List<Point> reEnter = new List<Point>();
                    Player plyrDestRobot =
                        Players.Where(pl => (pl.IsVisible) && (pl.Robot.Location.MapPosition == playerOn.Archive)).FirstOrDefault();
                    if (plyrDestRobot == null)
                        reEnter.Add(playerOn.Archive);
                    else
                    {
                        // ok, get all around the archive that aren't occupied.
                        for (int x = playerOn.Archive.X - 1; x <= playerOn.Archive.X + 1; x++)
                            for (int y = playerOn.Archive.Y - 1; y <= playerOn.Archive.Y + 1; y++)
                                if ((0 <= x) && (x < MainMap.Width) && (0 <= y) && (y < MainMap.Height))
                                {
                                    Point pt = new Point(x, y);
                                    plyrDestRobot = Players.Where(pl => (pl.IsVisible) && (pl.Robot.Location.MapPosition == pt)).FirstOrDefault();
                                    if (plyrDestRobot == null)
                                        reEnter.Add(pt);
                                }
                    }
                    playerOn.Robot.Location = new BoardLocation(reEnter[0], MapSquare.DIRECTION.NORTH); // until we get a reply.
                    playerOn.UnDestroy();
                    Trace.WriteLine(string.Format("un-destroy - Player: {0}, Lives {1}, Location(s) {2}", playerOn.Name,
                                                  playerOn.Lives, reEnter.ToArray()));

                    playerOn.WaitingForReply = Player.COMM_MODE.WAITING_FOR_LOCATION;
                    // we set this before the call requesting the position to avoid getting a reply before we set it.
                    if (playerOn.TcpGuid != null)
                        phaseOn = PHASE.WAITING_ON_ARCHIVE;
                    framework.RequestStartPosition(playerOn, reEnter, false);
                    continue;
                }

                MapSquare sq = MainMap.GetSquare(playerOn.Robot.Location.MapPosition);
                if ((sq.Type == MapSquare.TYPE.REPAIR) && IsRepairTurn)
                {
                    playerOn.Repair(playerOn.Robot.Location.MapPosition);
                    Trace.WriteLine(string.Format("repair - Player: {0}, damage {1}", playerOn.Name, playerOn.Damage));
                }
                ValidateData();
            }
            cardOn = 0;

            if (phaseOn != PHASE.WAITING_ON_ARCHIVE)
                return;

            // set up timeout as we're waiting. Check if we got everything.
            framework.WaitingForReentry();
            if (!Players.Any(pl => pl.WaitingForReply != Player.COMM_MODE.READY))
            {
                Trap.trap();
                phaseOn = PHASE.GET_TURN;
            }
        }
Exemple #21
0
 public void PegPhase(Player _player)
 {
     if(TurnCounter != Players.IndexOf(_player) && PhaseCounter != PHASE.PEG){
         return;
     }
     PhaseCounter = PHASE.MOVE;
 }
 void BeginBattle()
 {
     AudioManager.PlayBGM("Boss", TRANSITION.INSTANT);
     leftEye.CurrentHealth = leftEye.MaxHealth;
     rightEye.CurrentHealth = rightEye.MaxHealth;
     m_phase = PHASE.ONE;
     leftEye.Initialise();
     rightEye.Initialise();
     ModalPanel.Instance.bossPanel.SetActive(true);
     ModalPanel.Instance.bossHealth.value = MaxHealth;
     StartCoroutine("MoveToCenter");
 }
Exemple #23
0
 void SetPhase( PHASE phase, UInt64 waitTime )
 {
     m_Phase = phase;
     m_WaitTime = waitTime;
 }
Exemple #24
0
 private void setPhase(PHASE phase, STEP step)
 {
     EventHub.Signal (EventConstants.EndOfStep, null, null);
     EventHub.Signal (EventConstants.EndOfPhase, null, null);
     CurrentPhase = phase;
     CurrentStep = step;
     EventHub.Signal (EventConstants.StartOfPhase, null, null);
     EventHub.Signal (EventConstants.StartOfStep, null, null);
 }
 public static void ActionAttack(object[] args)
 {
     AI_Enemy.Action action = (AI_Enemy.Action)args[0];
     if (!action.unit.CheckAttack( action.target, Unit.UNIT_ATTACK.UNIT_ACTIVE_ATTACK))
     {
         Console.WriteLine("'{0}' ({1},{2}) can not attack '{3}' ({4},{5})",
                  action.unit.name, action.unit.x, action.unit.y,
                  action.target.name, action.target.x, action.target.y);
         return;
     }
     if (!Engine.map.mask[action.target.x, action.target.y].spot)
     {
         Console.WriteLine("'%{0}' may not attack unit '{1}' (not visible)", action.unit.name, action.target.name);
         return;
     }
     Engine.cur_unit = action.unit;
     Engine.cur_target = action.target;
     Engine.cur_unit.GetDefensiveFireUnits(Engine.cur_target, Scenario.units, ref Engine.df_units);
     if (Engine.engine_get_next_combatants())
     {
         Engine.status = STATUS.STATUS_ATTACK;
         Engine.phase = PHASE.PHASE_INIT_ATK;
         AI_Enemy.Action.action_queue(EngineActionsTypes.ACTION_INIT_ATTACK);
         //stateMachine.Send(EngineActionsTypes.ACTION_INIT_ATTACK);
         Engine.engine_clear_danger_mask();
     #if TODO
         if (Engine.cur_ctrl == PLAYER_CTRL_HUMAN)
             image_hide(gui.cursors, 1);
     #endif
     }
 }
Exemple #26
0
 public void Back(Player _player)
 {
     switch(PhaseCounter){
     case PHASE.PEG:
         //go back to play phase
         PhaseCounter = PHASE.PLAY;
         //return the last played card back into the palyers hand
         _player.Discard.Remove(_player.LastDiscarded);
         _player.Hand.Add(_player.LastDiscarded);
         _player.LastDiscarded = null;//may need more logic to retain the last last discarded
         LastPlayed = null;
         FirstPeg = null;
         SecondPeg = null;
         break;
     case PHASE.MOVE:
         FirstPeg = null;
         SecondPeg = null;
         PhaseCounter = PHASE.PEG;
         break;
     case PHASE.END:
         //having a stack of peg states would make this easy
         break;
     }
 }
        public static void CheckResult()
        {
            bool broken_up = false;
            bool reset = false;
            bool was_final_fight = false;
            bool surrender = false;
            try
            {
                UNIT_END_COMBAT type = UNIT_END_COMBAT.UNIT_STAYS;
                int dx, dy;

                surp_contact = false;

                /* check attack result */
                if ((atk_result & Unit.FIGHT_TYPES.AR_UNIT_KILLED) == Unit.FIGHT_TYPES.AR_UNIT_KILLED)
                {
                    Scenario.scen_inc_casualties_for_unit(cur_atk);
                    engine_remove_unit(cur_atk);
                    cur_atk = null;
                }
                if ((atk_result & Unit.FIGHT_TYPES.AR_TARGET_KILLED) == Unit.FIGHT_TYPES.AR_TARGET_KILLED)
                {
                    Scenario.scen_inc_casualties_for_unit(cur_def);
                    engine_remove_unit(cur_def);
                    cur_def = null;
                }
                /* CHECK IF SCENARIO IS FINISHED DUE TO UNITS_KILLED OR UNITS_SAVED */
                if (Scenario.scen_check_result(false))
                {
                    engine_finish_scenario();
                    return;
                }
                reset = true;
                if (df_units.Count > 0)
                {
                    if (((atk_result & Unit.FIGHT_TYPES.AR_TARGET_SUPPRESSED) == Unit.FIGHT_TYPES.AR_TARGET_SUPPRESSED) ||
                        ((atk_result & Unit.FIGHT_TYPES.AR_TARGET_KILLED) == Unit.FIGHT_TYPES.AR_TARGET_KILLED))
                    {
                        df_units.Clear();
                        if ((atk_result & Unit.FIGHT_TYPES.AR_TARGET_KILLED) == Unit.FIGHT_TYPES.AR_TARGET_KILLED)
                            cur_unit = null;
                        else
                        {
                            /* supressed unit looses its actions */
                            cur_unit.cur_mov = 0;
                            cur_unit.cur_atk_count = 0;
                            cur_unit.unused = false;
                            broken_up = true;
                        }
                    }
                    else
                    {
                        reset = false;
                        df_units.RemoveAt(0);
                    }
                }
                else
                    was_final_fight = true;
                if (!reset)
                {
                    /* continue fights */
                    if (engine_get_next_combatants())
                    {
                        status = STATUS.STATUS_ATTACK;
                        phase = PHASE.PHASE_INIT_ATK;
                    }
                    else
                        Console.WriteLine("Deadlock! No remaining combatants but supposed to continue fighting? How is this supposed to work????");
                }
                else
                {
                    /* clear suppression from defensive fire */
                    if (cur_atk != null)
                    {
                        cur_atk.suppr = 0;
                        cur_atk.unused = false;
                    }
                    if (cur_def != null)
                        cur_def.suppr = 0;
                    /* if this was the final fight between selected unit and selected target
                       check if one of these units was completely suppressed and surrenders
                       or flees */
                    if (was_final_fight)
                    {
                        engine_clear_backup(); /* no undo allowed after attack */
                        if (cur_atk != null && cur_def != null)
                        {
                            if ((atk_result & Unit.FIGHT_TYPES.AR_UNIT_ATTACK_BROKEN_UP) == Unit.FIGHT_TYPES.AR_UNIT_ATTACK_BROKEN_UP)
                            {
                                /* unit broke up the attack */
                                broken_up = true;
                            }
                            else
                                /* total suppression may only cause fleeing or
                                   surrender if: both units are ground/naval units in
                                   close combat: the unit that causes suppr must
                                   have range 0 (melee)
                                   inf . fort (fort may surrender)
                                   fort . adjacent inf (inf will not flee) */
                                if (((cur_atk.sel_prop.flags & UnitFlags.FLYING) != UnitFlags.FLYING) &&
                                    (cur_def.sel_prop.flags & UnitFlags.FLYING) != UnitFlags.FLYING)
                                {
                                    if ((atk_result & Unit.FIGHT_TYPES.AR_UNIT_SUPPRESSED) == Unit.FIGHT_TYPES.AR_UNIT_SUPPRESSED &&
                                         ((atk_result & Unit.FIGHT_TYPES.AR_TARGET_SUPPRESSED) != Unit.FIGHT_TYPES.AR_TARGET_SUPPRESSED) &&
                                         cur_def.sel_prop.rng == 0)
                                    {
                                        /* cur_unit is suppressed */
                                        engine_handle_suppr(cur_atk, out type, out dx, out dy);
                                        if (type == UNIT_END_COMBAT.UNIT_FLEES)
                                        {
                                            status = STATUS.STATUS_MOVE;
                                            phase = PHASE.PHASE_INIT_MOVE;
                                            move_unit = cur_atk;
                                            fleeing_unit = 1;
                                            dest_x = dx; dest_y = dy;
                                            return;
                                        }
                                        else
                                            if (type == UNIT_END_COMBAT.UNIT_SURRENDERS)
                                            {
                                                surrender = true;
                                                surrender_unit = cur_atk;
                                            }
                                    }
                                    else
                                        if ((atk_result & Unit.FIGHT_TYPES.AR_TARGET_SUPPRESSED) == Unit.FIGHT_TYPES.AR_TARGET_SUPPRESSED &&
                                             (atk_result & Unit.FIGHT_TYPES.AR_UNIT_SUPPRESSED) != Unit.FIGHT_TYPES.AR_UNIT_SUPPRESSED &&
                                             cur_atk.sel_prop.rng == 0)
                                        {
                                            /* cur_target is suppressed */
                                            engine_handle_suppr(cur_def, out type, out dx, out dy);
                                            if (type == UNIT_END_COMBAT.UNIT_FLEES)
                                            {
                                                status = STATUS.STATUS_MOVE;
                                                phase = PHASE.PHASE_INIT_MOVE;
                                                move_unit = cur_def;
                                                fleeing_unit = 1;
                                                dest_x = dx; dest_y = dy;
                                                return;
                                            }
                                            else
                                                if (type == UNIT_END_COMBAT.UNIT_SURRENDERS)
                                                {
                                                    surrender = true;
                                                    surrender_unit = cur_def;
                                                }
                                        }
                                }
                        }
                        /* clear pointers */
                        if (cur_atk == null) cur_unit = null;
                        if (cur_def == null) cur_target = null;
                    }
                    if (broken_up)
                    {
                        phase = PHASE.PHASE_BROKEN_UP_MSG;
                        Console.WriteLine("Attack Broken Up!");
                        return;
                    }
                    if (surrender)
                    {
                        string msg = (surrender_unit.sel_prop.flags & UnitFlags.SWIMMING) == UnitFlags.SWIMMING ?
                            "Ship is scuttled!" : "Surrenders!";
                        phase = PHASE.PHASE_SURRENDER_MSG;
                        Console.WriteLine(msg);
                        return;
                    }
                    phase = PHASE.PHASE_END_COMBAT;
                }
            }
            finally
            {
                AI_Enemy.Action.action_queue(EngineActionsTypes.ACTION_END_COMBAT);
                //stateMachine.Send(EngineActionsTypes.ACTION_END_COMBAT);
            }
        }
Exemple #28
0
 public void DiscardPhase(Player _player)
 {
     if(TurnCounter != Players.IndexOf(_player) && PhaseCounter != PHASE.PLAY){
         return;
     }
     if(_player.SelectedCard == -1){
         Debug.Log("you must select a card");
         return;
     }
     //discard selected card
     _player.Discard.Add(_player.LastDiscarded);
     _player.LastDiscarded = _player.Hand[_player.SelectedCard];
     LastPlayed = _player.Hand[_player.SelectedCard];
     _player.Hand.RemoveAt(_player.SelectedCard);
     //Player draws or Counts Depending on rule Set
     switch(RuleSet){
     case RULESET.CLASSIC:
         //_player.TakeCard(TableDeck.Draw());
         _player.Counting++;
         if(_player.Counting == 3){
             //move peg out of player's Home to Come Out space;
             //Peg select
             //PhaseCounter = PHASE.PEG
             _player.Counting = 0;
         }
         break;
     }
     //inc PhaseCounter
     PhaseCounter = PHASE.END;
 }
        public static void EndMove()
        {
            /* fade out sound */
            #if WITH_SOUND
                    audio_fade_out( 0, 500 ); /* move sound channel */
            #endif
            /* decrease fuel for way_pos hex tiles of movement */
            if (move_unit.CheckFuelUsage() && Config.supply)
            {
                move_unit.cur_fuel -= move_unit.CalcFuelUsage(  way_pos);
                if (move_unit.cur_fuel < 0)
                    move_unit.cur_fuel = 0;
            }
            /* clear move buffer image */
            #if TODO
                    if ( !blind_cpu_turn )
                       image_delete( &move_image );
            #endif
            /* run surprise contact */
            if (surp_unit != null)
            {
                cur_unit = move_unit;
                cur_target = surp_unit;
                surp_contact = true;
                surp_unit = null;
                if (engine_get_next_combatants())
                {
                    status = STATUS.STATUS_ATTACK;
                    phase = PHASE.PHASE_INIT_ATK;
                    if (!blind_cpu_turn)
                    {
            #if TODO
                                image_hide( gui.cursors, 1 );
            #endif
                        draw_map = true;
            #if TODO_RR
                        form.Draw();
            #endif
                    }
                }
                return;
            }
            /* reselect unit -- cur_unit may differ from move_unit! */
            if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_HUMAN)
                engine_select_unit(cur_unit);
            /* status */
            engine_set_status(STATUS.STATUS_NONE);
            phase = PHASE.PHASE_NONE;
            AI_Enemy.Action.action_queue(EngineActionsTypes.ACTION_NONE);
            //stateMachine.Send(EngineActionsTypes.ACTION_NONE);

            /* allow new human/cpu input */
            if (!blind_cpu_turn)
            {
                if (cur_ctrl == PLAYERCONTROL.PLAYER_CTRL_HUMAN)
                {
            #if TODO
                            gui_set_cursor( CURSOR_STD );
                            image_hide( gui.cursors, 0 );
                            old_mx = old_my = -1;
            #endif
                }
                draw_map = true;
            #if TODO_RR
                form.Draw();
            #endif
            }
        }
Exemple #30
0
        public void ChangePhase()
        {
            m_phase = m_phase == PHASE.DAY ? PHASE.NIGHT : PHASE.DAY;

            m_currentBehaviour = 0;

            if (m_phase == PHASE.DAY)
            {
                m_bgmDay.UnPause();
                m_bgmNight.Pause();

                m_turns++;
                InGameUI.Instance.SetTime(m_turns);

                if (m_respawnFood)
                {
                    int count = m_foodsToRespawn.Count;
                    for (int i = count - 1; i >= 0; i--)
                    {
                        if (m_foodsToRespawn[i].Respawn())
                        {
                            Food food = FruitPool.Instance.Load();

                            HexaTile tile = null;

                            int x = 0;
                            int y = 0;

                            while (tile == null)
                            {
                                x = Random.Range(0, m_mapSizeX);
                                y = Random.Range(0, m_mapSizeY);

                                if (x > 0 && x < Map.Instance.mapSizeX && y > 0 && y < Map.Instance.mapSizeY)
                                {
                                    tile = Map.Instance.GetTile(y, x);

                                    if (tile.data.animal != null || tile.data.bat != null || tile.data.food != null || tile.data.obstacle != null || tile.data.morceguita != null)
                                    {
                                        tile = null;
                                    }
                                }
                            }

                            food.Respawn(tile, m_foodsToRespawn[i].type);

                            m_foodsToRespawn.RemoveAt(i);
                        }
                    }
                }

                StartCoroutine(PlaneToDay());
            }
            else
            {
                m_bgmDay.Pause();
                m_bgmNight.UnPause();

                StartCoroutine(PlaneToNight());
            }
        }
 /*
 ====================================================================
 End the Scenario and display final message.
 ====================================================================
 */
 public static void engine_finish_scenario()
 {
     /* finalize ai turn if any */
     if (cur_player != null && cur_player.ctrl == PLAYERCONTROL.PLAYER_CTRL_CPU)
         cur_player.ai_finalize();
     blind_cpu_turn = false;
     engine_show_final_message();
     #if TODO
     group_set_active(gui.base_menu, ID_MENU, 0);
     #endif
     draw_map = false;
     #if TODO
     image_hide(gui.cursors, 0);
     gui_set_cursor(CURSOR_STD);
     #endif
     engine_select_player(null, false);
     Scenario.turn = Scenario.scen_info.turn_limit;
     engine_set_status(STATUS.STATUS_NONE);
     phase = PHASE.PHASE_NONE;
 }
Exemple #32
0
    public void EndPhase(Player _player)
    {
        if(TurnCounter != Players.IndexOf(_player) && PhaseCounter != PHASE.END){
            return;
        }
        _player.SelectedCard = -1;
        LastPlayed = null;
        FirstPeg = null;
        SecondPeg = null;
        MoveToDistanceFirst = -1;
        MoveToDistanceSecond = -1;

        //roll PhaseCounter
        PhaseCounter = PHASE.DRAW;
        //roll TurnCounter
        TurnCounter = (TurnCounter + 1) % Players.Count;
    }
Exemple #33
0
 //player's turn starts
 //player draws a card
 //player selects a Card to play, or discards
 //player selects a Peg(s) to move
 //(player draws or Counts)
 //player ends turn
 public void DrawPhase(Player _player)
 {
     if(TurnCounter != Players.IndexOf(_player) && PhaseCounter != PHASE.DRAW){
         return;
     }
     //player draws a card
     _player.TakeCard(TableDeck.Draw());
     //inc the PhaseCounter
     PhaseCounter = PHASE.PLAY;
 }
Exemple #34
0
 public override bool hasMovesLeft(PHASE argPhase)
 {
     return(false);
 }