コード例 #1
0
        private SideState _changeStatusForSide(SideState previousState, Vector pos, bool initial = false)
        {
            SideState state = previousState;

            if (Rooms.TileIsBlockedForRequirements(pos))
            {
                state = SideState.Blocked;
            }
            else if (Rooms.TileIsWall(pos))
            {
                if (initial)
                {
                    state = SideState.Wall;
                }
                else if (previousState == SideState.Free)
                {
                    state = SideState.Partial;
                }
            }
            else
            {
                if (initial)
                {
                    state = SideState.Free;
                }
                else if (previousState == SideState.Wall)
                {
                    state = SideState.Partial;
                }
            }

            return(state);
        }
コード例 #2
0
 private void setInnerSidesTo(Room room, SideState targetState = SideState.None)
 {
     foreach (Side side in getInnerSidesOnRoom(room))
     {
         side.State = targetState;
     }
 }
コード例 #3
0
        private static int _checkTwoRequirements(SideState side1, SideState side2, SideState both, SideState required1, SideState required2)
        {
            int sideScore;
            var bothAreFulfilled = (side1 & required1) > 0 && (side2 & required2) > 0 || (side1 & required2) > 0 && (side2 & required1) > 0;
            var atLeastOne       = (both & required1) > 0 || (both & required2) > 0;

            // higher penalty for blocked?
            sideScore = bothAreFulfilled ? 0 : atLeastOne ? 1 : 2;
            return(sideScore);
        }
コード例 #4
0
    /// <summary>
    /// Tutorial
    /// </summary>
    private void SubInitialiseTutorial()
    {
        Tutorial tutorial = GameManager.i.tutorialScript.tutorial;

        if (tutorial != null)
        {
            //HUMAN Player
            switch (tutorial.side.level)
            {
            case 1:
                //Authority player
                PlayerSide = globalAuthority;
                Debug.Log("[Start] Player set to AUTHORITY side");
                resistanceOverall = SideState.AI;
                authorityOverall  = SideState.Human;
                resistanceCurrent = SideState.AI;
                authorityCurrent  = SideState.Human;
                //names
                GameManager.i.playerScript.SetPlayerNameResistance(GameManager.i.scenarioScript.scenario.leaderResistance.leaderName);
                GameManager.i.playerScript.SetPlayerNameAuthority(GameManager.i.preloadScript.nameAuthority);
                break;

            case 2:
                //Resistance player
                PlayerSide = GameManager.i.globalScript.sideResistance;
                Debug.Log("[Start] Player set to RESISTANCE side");
                resistanceOverall = SideState.Human;
                authorityOverall  = SideState.AI;
                resistanceCurrent = SideState.Human;
                authorityCurrent  = SideState.AI;
                //names
                GameManager.i.playerScript.SetPlayerNameResistance(GameManager.i.preloadScript.nameResistance);
                GameManager.i.playerScript.SetPlayerNameAuthority(GameManager.i.scenarioScript.scenario.leaderAuthority.mayorName);
                break;

            default:
                Debug.LogWarningFormat("Unrecognised tutorial side \"{0}\"", tutorial.side.name);
                break;
            }
            //set first name
            GameManager.i.playerScript.SetPlayerFirstName(GameManager.i.preloadScript.nameFirst);
        }
        else
        {
            Debug.LogError("Invalid tutorial (Null)");
        }
    }
コード例 #5
0
        private int _getSideScore(SideRequirement sideReq, SideState side1, SideState side2)
        {
            var sideScore = 0;

            var both = (side1 | side2);

            if (PlaceableObject.PlaceFarAway && (both & SideState.Blocked) > 0)
            {
                sideScore += 5;
            }

            switch (sideReq)
            {
            case SideRequirement.None:
                sideScore = 0;
                break;

            case SideRequirement.OneFree:
                sideScore += (both & SideState.Free) > 0 ? 0 : 1;
                break;

            case SideRequirement.OneWall:
                sideScore += (both & SideState.Wall) > 0 ? 0 : 1;
                break;

            case SideRequirement.OneWallOneFree:
                sideScore += _checkTwoRequirements(side1, side2, both, SideState.Free, SideState.Wall);
                break;

            case SideRequirement.TwoFree:
                sideScore += _checkTwoRequirements(side1, side2, both, SideState.Free, SideState.Free);
                break;

            case SideRequirement.TwoWalls:
                sideScore += _checkTwoRequirements(side1, side2, both, SideState.Wall, SideState.Wall);
                break;
            }

            return(sideScore);
        }
コード例 #6
0
        void _checkForSideStates(
            int dimX,
            int dimY,
            Vector position,
            out SideState upState, out SideState downState, out SideState leftState, out SideState rightState)
        {
            upState    = SideState.None;
            downState  = SideState.None;
            leftState  = SideState.None;
            rightState = SideState.None;

            var noContinueStates = SideState.Blocked | SideState.Partial;

            for (int wOff = 0;
                 ((upState & noContinueStates) == 0 || (downState & noContinueStates) == 0) &&
                 wOff < dimX;
                 wOff++)
            {
                var up   = position.AddXY(wOff, -1);
                var down = position.AddXY(wOff, dimY);

                upState = _changeStatusForSide(upState, up, wOff == 0 ? true : false);

                downState = _changeStatusForSide(downState, down, wOff == 0 ? true : false);
            }

            for (int hOff = 0;
                 ((leftState & noContinueStates) == 0 || (rightState & noContinueStates) == 0) &&
                 hOff < dimY;
                 hOff++)
            {
                var left  = position.AddXY(-1, hOff);
                var right = position.AddXY(dimX, hOff);

                leftState = _changeStatusForSide(leftState, left, hOff == 0 ? true : false);

                rightState = _changeStatusForSide(rightState, right, hOff == 0 ? true : false);
            }
        }
コード例 #7
0
ファイル: FieldGenerator.cs プロジェクト: uu3474/networkgame
 static void SetSideStataToAdjacentCells(CellData cell1, CellData cell2, SideState sideState)
 {
     if (cell1.XIndex > cell2.XIndex)
     {
         cell2.RightSide = sideState;
         cell1.LeftSide  = sideState;
     }
     else if (cell1.YIndex > cell2.YIndex)
     {
         cell2.BottomSide = sideState;
         cell1.TopSide    = sideState;
     }
     else if (cell1.XIndex < cell2.XIndex)
     {
         cell2.LeftSide  = sideState;
         cell1.RightSide = sideState;
     }
     else if (cell1.YIndex < cell2.YIndex)
     {
         cell2.TopSide    = sideState;
         cell1.BottomSide = sideState;
     }
 }
コード例 #8
0
 private void Awake()
 {
     ParentState = transform.parent.GetComponent <SideState>();
 }
コード例 #9
0
ファイル: SideManager.cs プロジェクト: jcnast/Commander
 // side select has started
 void StartSideSelect(StartSideSelectEvent e)
 {
     curState = SideState.SideSelect;
     // get all the BaseTile components of the tiles
     sideBaseTiles = new BaseTile[sidePieces.Length];
     for(int i = 0; i < sidePieces.Length; i++){
         sideBaseTiles[i] = sidePieces[i].GetComponent<BaseTile>();
     }
     // light up all tiles along the side
     LightAllTiles(true);
 }
コード例 #10
0
ファイル: SideManager.cs プロジェクト: jcnast/Commander
    // check if this side is doing unit placement
    void PlaceUnits(PlaceUnitsEvent e)
    {
        if(e.Side == gameObject){
            LightAllTiles(true);

            curState = SideState.UnitPlacing;
        }
    }
コード例 #11
0
ファイル: SideManager.cs プロジェクト: jcnast/Commander
    void UnitsPlaced(UnitsPlacedEvent e)
    {
        if(curState == SideState.UnitPlacing){
            LightAllTiles(false);

            curState = SideState.None;
        }
    }
コード例 #12
0
 public Side(RoomBlock parentRoomBlock, Vector2 direction, SideState state = SideState.Wall)
 {
     ParentRoomBlock = parentRoomBlock;
     Direction       = direction;
     State           = state;
 }
コード例 #13
0
    /// <summary>
    /// At the completion of an AI vs AI autorun the specified Player side reverts back to Human Control
    /// </summary>
    public void RevertToHumanPlayer()
    {
        int           power;
        ActorStatus   status;
        ActorInactive inactiveStatus;
        float         inactiveAlpha = GameManager.i.guiScript.alphaInactive;
        float         activeAlpha   = GameManager.i.guiScript.alphaActive;

        //flashing red alert at top UI for Security Status -> switch on/off
        if (GameManager.i.turnScript.authoritySecurityState != AuthoritySecurityState.Normal)
        {
            EventManager.i.PostNotification(EventType.StartSecurityFlash, this, null, "SideManager.cs -> RevertToHumanPlayer");
        }
        else
        {
            EventManager.i.PostNotification(EventType.StopSecurityFlash, this, null, "SideManager.cs -> RevertToHumanPlayer");
        }
        switch (_playerSide.level)
        {
        case 1:
            //
            // - - - Authority - - -
            //
            authorityOverall  = SideState.Human;
            authorityCurrent  = SideState.Human;
            resistanceOverall = SideState.AI;
            resistanceCurrent = SideState.AI;
            //convert resources to power
            power = GameManager.i.dataScript.CheckAIResourcePool(globalAuthority);
            Debug.LogFormat("[Aim] SideManager.cs -> RevertToHumanPlayer: Authority has {0} Resources{1}", power, "\n");
            power /= GameManager.i.aiScript.powerFactor;
            GameManager.i.playerScript.Power = power;
            //update states
            status         = GameManager.i.aiScript.status;
            inactiveStatus = GameManager.i.aiScript.inactiveStatus;
            GameManager.i.playerScript.status         = status;
            GameManager.i.playerScript.inactiveStatus = inactiveStatus;
            GameManager.i.playerScript.isBreakdown    = GameManager.i.aiScript.isBreakdown;
            //player
            switch (status)
            {
            case ActorStatus.Inactive:
                switch (inactiveStatus)
                {
                case ActorInactive.Breakdown:
                    //reduce player alpha to show inactive (sprite and text)
                    GameManager.i.actorPanelScript.UpdatePlayerAlpha(inactiveAlpha);
                    GameManager.i.playerScript.tooltipStatus = ActorTooltip.Breakdown;
                    break;

                case ActorInactive.None:
                    //change actor alpha to show active (sprite and text)
                    GameManager.i.actorPanelScript.UpdatePlayerAlpha(activeAlpha);
                    GameManager.i.playerScript.tooltipStatus = ActorTooltip.None;
                    break;
                }
                break;
            }
            //clear out debug NodeActionData records for Player
            GameManager.i.playerScript.ClearAllNodeActions();
            //loop actors and check for status
            Actor[] arrayOfActors = GameManager.i.dataScript.GetCurrentActorsFixed(globalAuthority);
            if (arrayOfActors != null)
            {
                for (int i = 0; i < arrayOfActors.Length; i++)
                {
                    //check actor is present in slot (not vacant)
                    if (GameManager.i.dataScript.CheckActorSlotStatus(i, globalAuthority) == true)
                    {
                        Actor actor = arrayOfActors[i];
                        if (actor != null)
                        {
                            switch (actor.inactiveStatus)
                            {
                            case ActorInactive.Breakdown:
                                //change actor alpha to show inactive (sprite and text)
                                GameManager.i.actorPanelScript.UpdateActorAlpha(actor.slotID, inactiveAlpha);
                                actor.tooltipStatus = ActorTooltip.Breakdown;
                                break;

                            case ActorInactive.None:
                                //change actor alpha to show active (sprite and text)
                                GameManager.i.actorPanelScript.UpdateActorAlpha(actor.slotID, activeAlpha);
                                actor.tooltipStatus = ActorTooltip.None;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("Invalid arrayOfActors (Null)");
            }
            //teams need actors assigned
            GameManager.i.teamScript.AutoRunAssignActors();
            Debug.LogFormat("[Ply] SideManager.cs -> RevertToHumanPlayer: Authority side now under HUMAN control{0}", "\n");
            break;

        case 2:
            //
            // - - - Resistance - - -
            //
            resistanceOverall = SideState.Human;
            resistanceCurrent = SideState.Human;
            authorityOverall  = SideState.AI;
            authorityCurrent  = SideState.AI;
            GameManager.i.nemesisScript.SetResistancePlayer(SideState.Human);
            //convert resources to power
            power = GameManager.i.dataScript.CheckAIResourcePool(globalResistance);
            Debug.LogFormat("[Rim] SideManager.cs -> RevertToHumanPlayer: Resistance has {0} Resources{1}", power, "\n");
            power /= GameManager.i.aiRebelScript.powerFactor;
            GameManager.i.playerScript.Power = power;
            //update states
            status         = GameManager.i.aiRebelScript.status;
            inactiveStatus = GameManager.i.aiRebelScript.inactiveStatus;
            GameManager.i.playerScript.status         = status;
            GameManager.i.playerScript.inactiveStatus = inactiveStatus;
            GameManager.i.playerScript.isBreakdown    = GameManager.i.aiScript.isBreakdown;
            //testManager.cs Invisibility
            if (GameManager.i.testScript.playerInvisibility > -1)
            {
                GameManager.i.playerScript.Invisibility = GameManager.i.testScript.playerInvisibility;
            }
            //player
            switch (status)
            {
            case ActorStatus.Captured:
                GameManager.i.playerScript.tooltipStatus = ActorTooltip.Captured;
                //reduce player alpha to show inactive (sprite and text)
                GameManager.i.actorPanelScript.UpdatePlayerAlpha(inactiveAlpha);
                break;

            case ActorStatus.Inactive:
                //reduce player alpha to show inactive (sprite and text)
                GameManager.i.actorPanelScript.UpdatePlayerAlpha(inactiveAlpha);
                switch (inactiveStatus)
                {
                case ActorInactive.Breakdown:
                    GameManager.i.playerScript.tooltipStatus = ActorTooltip.Breakdown;
                    break;

                case ActorInactive.LieLow:
                    GameManager.i.playerScript.tooltipStatus = ActorTooltip.LieLow;
                    break;

                case ActorInactive.None:
                    //change actor alpha to show active (sprite and text)
                    GameManager.i.actorPanelScript.UpdatePlayerAlpha(activeAlpha);
                    GameManager.i.playerScript.tooltipStatus = ActorTooltip.None;
                    break;
                }
                break;
            }
            //clear out debug NodeActionData records for Player
            GameManager.i.playerScript.ClearAllNodeActions();
            //loop actors and check for status
            arrayOfActors = GameManager.i.dataScript.GetCurrentActorsFixed(globalResistance);
            if (arrayOfActors != null)
            {
                for (int i = 0; i < arrayOfActors.Length; i++)
                {
                    //check actor is present in slot (not vacant)
                    if (GameManager.i.dataScript.CheckActorSlotStatus(i, globalResistance) == true)
                    {
                        Actor actor = arrayOfActors[i];
                        if (actor != null)
                        {
                            //clear out debug NodeActionData records
                            actor.RemoveAllNodeActions();
                            //update
                            switch (actor.Status)
                            {
                            case ActorStatus.Active:

                                // - - - Compatibility (Edit: cause duplicate msg)
                                // - - - Invisibility Zero warning (Edit: causes duplicate msg)

                                /*//
                                 * // - - - Motivation Warning - - -  EDIT -> Duplicate message
                                 * //
                                 * if (actor.GetDatapoint(ActorDatapoint.Motivation1) == 0)
                                 * { GameManager.instance.actorScript.ProcessMotivationWarning(actor); }*/

                                break;

                            case ActorStatus.Captured:
                                //change actor alpha to show inactive (sprite and text)
                                GameManager.i.actorPanelScript.UpdateActorAlpha(actor.slotID, inactiveAlpha);
                                actor.tooltipStatus = ActorTooltip.Captured;
                                break;

                            case ActorStatus.Inactive:
                                switch (actor.inactiveStatus)
                                {
                                case ActorInactive.Breakdown:
                                    //change actor alpha to show inactive (sprite and text)
                                    GameManager.i.actorPanelScript.UpdateActorAlpha(actor.slotID, inactiveAlpha);
                                    actor.tooltipStatus = ActorTooltip.Breakdown;
                                    break;

                                case ActorInactive.LieLow:
                                    GameManager.i.actorPanelScript.UpdateActorAlpha(actor.slotID, inactiveAlpha);
                                    actor.tooltipStatus = ActorTooltip.LieLow;
                                    break;

                                case ActorInactive.None:
                                    //change actor alpha to show active (sprite and text)
                                    GameManager.i.actorPanelScript.UpdateActorAlpha(actor.slotID, activeAlpha);
                                    actor.tooltipStatus = ActorTooltip.None;
                                    break;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("Invalid arrayOfActors (Null)");
            }

            //DEBUG -> add false (but more accurate) NodeAction records for testing purposes
            GameManager.i.actorScript.DebugCreateNodeActionResistanceData();

            //Gear
            int gearUsed   = GameManager.i.aiRebelScript.GetGearUsedAdjusted();
            int gearPoints = 0;
            if (GameManager.i.testScript.numOfGearItems == -1)
            {
                //normal gear point allocation according to AI gear pool
                gearPoints = GameManager.i.aiRebelScript.GetGearPoints();
                /*Debug.LogFormat("[Tst] SideManager.cs -> RevertToHumanPlayer: Rebel AIManager Gear points set to {0}{1}", gearPoints, "\n");*/
            }
            else
            {
                //Test Manager specified gear points
                gearPoints = GameManager.i.testScript.numOfGearItems;
                /*Debug.LogFormat("[Tst] SideManager.cs -> RevertToHumanPlayer: TestManager Gear points set to {0}{1}", gearPoints, "\n");*/
            }
            if (gearUsed > 0)
            {
                //delete gear from common and rare pools to reflect gear that's been used
                GameManager.i.dataScript.UpdateGearLostOnRevert(gearUsed);
            }
            if (gearPoints > 0)
            {
                //add gear to reflect gear that is currently in use
                GameManager.i.dataScript.UpdateGearCurrentOnRevert(gearPoints);
            }
            Debug.LogFormat("[Ply] SideManager.cs -> RevertToHumanPlayer: Resistance side now under HUMAN control{0}", "\n");
            break;

        default:
            Debug.LogError(string.Format("Invalid _playerSide.level \"{0}\"", _playerSide.level));
            break;
        }
        //
        // - - - Events of note occur during the AutoRun
        //
        ShowAutoRunMessage();
    }
コード例 #14
0
    private void SubInitialiseSessionStart()
    {
        Campaign campaign = GameManager.i.campaignScript.campaign;

        if (campaign != null)
        {
            //AUTORUN (first scenario in a campaign only)
            if (GameManager.i.autoRunTurns > 0 && GameManager.i.campaignScript.CheckIsFirstScenario() == true)
            {
                //Campaign determines what side will be Player side (for GUI and Messages once auto run finished)
                switch (campaign.side.level)
                {
                case 1:
                    //Authority
                    PlayerSide = globalAuthority;
                    //reverts to Human authority player
                    GameManager.i.playerScript.SetPlayerNameAuthority(GameManager.i.preloadScript.nameAuthority);
                    GameManager.i.playerScript.SetPlayerNameResistance(GameManager.i.campaignScript.scenario.leaderResistance.leaderName);
                    break;

                case 2:
                    //Resistance
                    PlayerSide = globalResistance;
                    //reverts to Human resistance player
                    GameManager.i.playerScript.SetPlayerNameAuthority(GameManager.i.campaignScript.scenario.leaderAuthority.name);
                    GameManager.i.playerScript.SetPlayerNameResistance(GameManager.i.preloadScript.nameResistance);
                    break;

                default:
                    Debug.LogWarningFormat("Unrecognised campaign side \"{0}\"", campaign.side.name);
                    break;
                }
                Debug.Log("[Start] Player set to AI for both sides");
                resistanceOverall = SideState.AI;
                authorityOverall  = SideState.AI;
                resistanceCurrent = SideState.AI;
                authorityCurrent  = SideState.AI;
            }
            else
            {
                //HUMAN Player
                switch (campaign.side.level)
                {
                case 1:
                    //Authority player
                    PlayerSide = globalAuthority;
                    Debug.Log("[Start] Player set to AUTHORITY side");
                    resistanceOverall = SideState.AI;
                    authorityOverall  = SideState.Human;
                    resistanceCurrent = SideState.AI;
                    authorityCurrent  = SideState.Human;
                    //names
                    GameManager.i.playerScript.SetPlayerNameResistance(GameManager.i.campaignScript.scenario.leaderResistance.leaderName);
                    GameManager.i.playerScript.SetPlayerNameAuthority(GameManager.i.preloadScript.nameAuthority);
                    break;

                case 2:
                    //Resistance player
                    PlayerSide = GameManager.i.globalScript.sideResistance;
                    Debug.Log("[Start] Player set to RESISTANCE side");
                    resistanceOverall = SideState.Human;
                    authorityOverall  = SideState.AI;
                    resistanceCurrent = SideState.Human;
                    authorityCurrent  = SideState.AI;
                    //names
                    GameManager.i.playerScript.SetPlayerNameResistance(GameManager.i.preloadScript.nameResistance);
                    GameManager.i.playerScript.SetPlayerNameAuthority(GameManager.i.campaignScript.scenario.leaderAuthority.mayorName);
                    break;

                default:
                    Debug.LogWarningFormat("Unrecognised campaign side \"{0}\"", campaign.side.name);
                    break;
                }
            }
            //set first name
            GameManager.i.playerScript.SetPlayerFirstName(GameManager.i.preloadScript.nameFirst);
        }
        else
        {
            Debug.LogError("Invalid campaign (Null)");
        }
    }