Exemplo n.º 1
0
 // Create any kind of move except set attribute
 internal static MovePartModel Create(MoveKinds kind, PlayerValue player, PositionValue position, PieceValue piece,
                                      PositionValue final = null)
 {
     return(new MovePartModel {
         Kind = kind, Player = player, Piece = piece, Position = position, Final = final,
     });
 }
Exemplo n.º 2
0
 // set result, and remember current player if win or loss
 void SetMoveResult(ResultKinds result)
 {
     if (result == ResultKinds.Count)
     {
         // count means that player with highest count wins
         var ap = _gamedef.ActivePlayers.ToArray();
         if (ap.Length != 2)
         {
             throw Error.Assert("player count");
         }
         var counts = ap.Select(p => PiecesCount(p)).ToArray();
         _result       = (counts[0] == counts[1]) ? ResultKinds.Draw : ResultKinds.Win;
         _resultplayer = (_result == ResultKinds.Draw) ? PlayerValue.None : (counts[0] > counts[1]) ? ap[0] : ap[1];
     }
     else
     {
         _result       = result;
         _resultplayer = (result == ResultKinds.None || result == ResultKinds.Draw) ? PlayerValue.None : CurrentPlayer;
     }
     // credit non-active result to previous active player; or else to current
     if (_resultplayer == LastMovePlayer)
     {
         _resultplayer = LastTurnPlayer;
     }
     else if (_resultplayer == MovePlayer)
     {
         _resultplayer = TurnPlayer;
     }
 }
Exemplo n.º 3
0
 void s_Symmetry(PlayerValue player, List <Pair <DirectionValue, DirectionValue> > directionpairs)
 {
     foreach (var dirpair in directionpairs)
     {
         _boarddef.AddSymmetry(player, dirpair.Item1, dirpair.Item2);
     }
 }
Exemplo n.º 4
0
        public override void NodeGUI()
        {
            // value = RTEditorGUI.FloatField(new GUIContent("Value", "The input value of type float"), value);
            inputType = (InputType)RTEditorGUI.EnumPopup(new GUIContent("Input type:", ""), inputType);
            RTEditorGUI.Space();

            switch (inputType)
            {
            case InputType.player:
                playerValue = (PlayerValue)RTEditorGUI.EnumPopup(new GUIContent("Players value:", ""), playerValue);
                break;

            case InputType.agent:
                agentValue = (AgentValue)RTEditorGUI.EnumPopup(new GUIContent("This Agents value:", ""), agentValue);
                break;

            case InputType.world:
                worldValue = (WorldValue)RTEditorGUI.EnumPopup(new GUIContent("The Worlds value:", ""), worldValue);
                break;

            default:
                break;
            }

            outputKnob.SetPosition();

            if (GUI.changed)
            {
                NodeEditor.curNodeCanvas.OnNodeChange(this);
            }
        }
Exemplo n.º 5
0
 internal static PolyZone Create(ZoneValue name, PlayerValue player, IEnumerable <PositionValue> positions)
 {
     return(new PolyZone {
         Name = name.Value,
         Player = player.Value,
         Positions = positions.Select(p => p.Value).OrderBy(p => p).Join(" "),
     });
 }
Exemplo n.º 6
0
 void Awake()
 {
     itemPool     = new Queue <GameObject>();
     instance     = gameObject;
     standardItem = item;
     SlowSpeedData.ResetDataSet();
     PV = FindObjectOfType <PlayerValue>();
 }
Exemplo n.º 7
0
 internal static PolyOffStore Create(PlayerValue player, PieceValue piece, int quantity)
 {
     return(new PolyOffStore {
         Player = player.Value,
         Piece = piece.Value,
         Quantity = quantity,
     });
 }
Exemplo n.º 8
0
 internal static PolyPieceImage Create(PieceValue piece, PlayerValue player, IList <TextValue> image)
 {
     return(new PolyPieceImage {
         Piece = piece.Value,
         Player = player.Value,
         Images = image.Select(i => i.Value).ToList(),
     });
 }
Exemplo n.º 9
0
        // Create set attribute move
        internal static MovePartModel CreateSetAttribute(PlayerValue player, PositionValue position, PieceValue piece,
                                                         IdentValue ident, TypedValue value)
        {
            var mpm = Create(MoveKinds.Attrib, player, position, piece);

            mpm.Attribute = ident;
            mpm.Value     = value;
            return(mpm);
        }
Exemplo n.º 10
0
 // factory: flags default to empty
 internal static PieceModel Create(PlayerValue player, PieceDef piecedef)
 {
     return(new PieceModel {
         Def = piecedef,
         Player = player,
         Piece = piecedef.Piece,
         AttributeLookup = piecedef.AttributeLookup,
         LongHash = HashMaker.GetHash(piecedef.Piece) ^ HashMaker.GetHash(player),
     });
 }
Exemplo n.º 11
0
        // get position from position and direction
        internal PositionValue GetPosition(PositionValue position, PlayerValue player, DirectionValue direction)
        {
            if (!LinkLookup.ContainsKey(position))
            {
                return(null);
            }
            var newdir = SymmetryLookup.SafeLookup(Pair.Create(player, direction)) ?? direction;
            var link   = LinkLookup[position].FirstOrDefault(k => k.Direction == newdir);

            return((link == null) ? null : link.To);
        }
Exemplo n.º 12
0
 public void Vote(PlayerValue playerValue)
 {
     for (int i = 0; i < containerAnswers.Count; i++)
     {
         var answer = containerAnswers[i];
         if (answer.answerKey == playerValue)
         {
             answer.ValidatedOn();
         }
     }
 }
Exemplo n.º 13
0
        // iterate all adjacent positions for player
        internal IEnumerable <PositionValue> AdjacentIter(PositionValue position, PlayerValue player)
        {
            var links = LinkLookup.SafeLookup(position); // might be no links on this position

            if (links != null)
            {
                foreach (var link in links)
                {
                    yield return(link.To);
                }
            }
        }
Exemplo n.º 14
0
 void Start()
 {
     PV               = FindObjectOfType <PlayerValue>();
     trafficManager   = FindObjectOfType <TrafficLightsScripts>();
     itemsSpawn       = FindObjectOfType <ItemSpawn>();
     time             = 0f;
     PV.colorOfPlayer = PlayerPrefs.GetInt("colorOfPlayer");
     charGWalking.SetActive(false);
     charYWalking.SetActive(false);
     charRWalking.SetActive(false);
     ChooseColor();
 }
Exemplo n.º 15
0
 void Awake()
 {
     PV = FindObjectOfType <PlayerValue>();
     if (PV.colorOfPlayer == 2)
     {
         PV.life = 1;
     }
     else
     {
         PV.life = 0;
     }
 }
Exemplo n.º 16
0
 // check friend/enemy based on CurrentPlayer
 internal PlayerKinds GetPlayerKind(PlayerValue player)
 {
     if (player == CurrentPlayer)
     {
         return(PlayerKinds.Friend);
     }
     if (_gamedef.PlayerLookup[player].IsNeutral)
     {
         return(PlayerKinds.Neutral);
     }
     return(PlayerKinds.Enemy);
 }
Exemplo n.º 17
0
 void Awake()
 {
     PV = FindObjectOfType <PlayerValue>();
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 18
0
 private void but_Confirm_Click(object sender, EventArgs e)
 {
     foreach (Player tem in GameValue.Players)
     {
         if (tem.Name == txt_PlayerName.Text)
         {
             MessageBox.Show("【错误】无法创建角色" + "\r\n" + "已存在名为【" + tem.Name + "】的角色");
             return;
         }
     }
     PlayerValue.PlayerCreate(txt_PlayerName.Text, cbx_PlayerPrefession.Text);
     Dispose();
 }
Exemplo n.º 19
0
        internal PlayerValue NextOwner(PlayerValue player)
        {
            var found = false;

            foreach (var p in _gamedef.ActivePlayers)
            {
                if (found)
                {
                    return(p);
                }
                found = (p == player);
            }
            return(_gamedef.ActivePlayers.First());
        }
Exemplo n.º 20
0
 internal void AddDrop(PlayerValue player, PositionValue position, PieceValue piece)
 {
     _changes.Add(MovePartModel.Create(MoveKinds.Drop, player, position, piece));
 }
Exemplo n.º 21
0
 public void Vote(Player player, PlayerValue playerValue)
 {
     DialogueSystem.Instance.Vote(playerValue);
 }
Exemplo n.º 22
0
 // factory: parts default to empty
 internal static MoveModel Create(PlayerValue player, PositionValue position, PieceValue piece)
 {
     return(new MoveModel {
         Player = player, Position = position, Piece = piece,
     });
 }
Exemplo n.º 23
0
 void Awake()
 {
     PV = FindObjectOfType <PlayerValue>();
 }
Exemplo n.º 24
0
 // count pieces remaining for player
 internal int PiecesCount(PlayerValue player, PieceValue piece = null)
 {
     return(_playedpieces.Where(p => piece == null || p.Value.Piece == piece)
            .Where(p => p.Value.Player == player)
            .Count());
 }
Exemplo n.º 25
0
 IEnumerable <PositionValue> PositionIter(PlayerValue player, ZoneValue zone)
 {
     return(Def.ZoneLookup.SafeLookup(Pair.Create(zone, player)));
 }
Exemplo n.º 26
0
 void Awake()
 {
     instance       = gameObject;
     storedTraffics = new Queue <GameObject>();
     PV             = FindObjectOfType <PlayerValue>();
 }
Exemplo n.º 27
0
        internal void IncOffStore(PlayerValue player, PieceValue piece, int increment)
        {
            var pair = Pair.Create(player, piece);

            OffStoreLookup[pair] += increment;
        }
Exemplo n.º 28
0
        internal int OffStoreCount(PlayerValue player, PieceValue piece)
        {
            var pair = Pair.Create(player, piece);

            return(OffStoreLookup.SafeLookup(pair)); // conveniently zero if not found
        }
Exemplo n.º 29
0
 // create a piece for a player
 internal PieceModel CreatePiece(PlayerValue player, PieceValue piece)
 {
     return(PieceModel.Create(player, Def.PieceLookup[piece]));
 }
Exemplo n.º 30
0
 internal void AddChangeOwner(PositionValue position, PlayerValue player)
 {
     _changes.Add(MovePartModel.Create(MoveKinds.Owner, player, position, Piece));
 }