Inheritance: MonoBehaviour
Esempio n. 1
0
        public void PlayerCreated(object sender, PlayerCreatedEventArgs pcea)
        {
            Peer peer1    = (Peer)sender;
            int  playerID = pcea.Message.PlayerID;
            PlayerInformation playerInfo = peer1.GetPeerInformation(playerID);


            if (playerInfo.Local)
            {
                ID   = playerID;
                Name = playerInfo.Name;
            }
            else
            {
                Heli.Helicopter h         = new Heli.Helicopter(playerInfo.Name + playerID, @"dane\heliData.xml", true);
                RemotePlayer    newPlayer = new RemotePlayer(playerID, playerInfo.Name, h);


                curLevel.AddObject(h);

                factory.InsertObject(h);
                lock (otherPlayers)
                {
                    otherPlayers.Add(playerID, newPlayer);
                }
            }
        }
Esempio n. 2
0
    void Death(GameObject player)
    {
        isDead = true;
        EnemyManager.enemiesLeft -= 1;

        //add kill count to person who killed enemy
        PlayerInformation playerInfo = player.GetComponent <PlayerInformation>();

        //f/coins in future?
        //f/playerInfo.coins += coinValue;
        playerInfo.enemiesKilled += 1;

        //large blood stain effect
        Vector3    tempVector   = Random.rotation.eulerAngles;
        Quaternion tempRotation = Quaternion.Euler(0, 0, tempVector.z);
        GameObject bloodClone   = Instantiate(largeBloodStain, transform.position, tempRotation);

        //prevents lag
        Destroy(bloodClone, 60);

        //random rotation on corpse
        transform.rotation = Quaternion.Euler(0, 0, Random.Range(-180f, 180f));
        anim.SetBool("Dead", true);
        isFading = true;
        Destroy(gameObject, fadeTime + 1);
    }
Esempio n. 3
0
 void Update()
 {
     _PlayerRef = GameDataContainer.Instance.GDC.PlayerInfo;
     _MousePos  = Camera.main.ScreenPointToRay(Input.mousePosition).GetPoint(Camera.main.transform.position.y);
     this.transform.LookAt(_MousePos, this.transform.up);
     this.transform.rotation = Quaternion.Euler(new Vector3(-90, this.transform.rotation.eulerAngles.y + 180, 0));
 }
        // DECODIFICA.
        private static PlayerInformation getDecodifyPlayer(string pNickName, string playerInfo)
        {
            PlayerInformation ret = null;

            string[] str = playerInfo.Split(new string[] { UserInterfaceGraphics.MODES[0] }, System.StringSplitOptions.None);
            if (str == null || str.Length < 2)
            {
                // Es modo normal o difícil.
                str = playerInfo.Split(new string[] { UserInterfaceGraphics.MODES[1] }, System.StringSplitOptions.None);
                if (str == null || str.Length < 2)
                {
                    // Es modo difícil.
                    str = playerInfo.Split(new string[] { UserInterfaceGraphics.MODES[2] }, System.StringSplitOptions.None);
                    if (str == null || str.Length < 2)
                    {
                        return(null); // CASO DE ERROR.
                    }
                    else
                    {
                        ret = new PlayerInformation(pNickName, System.Int32.Parse(str[0]), 2, System.Int32.Parse(str[1]));
                    }
                }
                else
                {
                    ret = new PlayerInformation(pNickName, System.Int32.Parse(str[0]), 1, System.Int32.Parse(str[1]));
                }
            }
            else
            {
                ret = new PlayerInformation(pNickName, System.Int32.Parse(str[0]), 0, System.Int32.Parse(str[1]));
            }
            return(ret);
        }
Esempio n. 5
0
 /// <summary>
 /// Starts the game
 /// </summary>
 public void ClickPlayButton()
 {
     AudioManager.GetInstance().ClickSound();
     PauseMenuController.isPaused = false;
     PlayerInformation.GetInstance().RestartGame();
     SceneManager.LoadScene(firstStage);
 }
Esempio n. 6
0
        internal static PlayerMove PlayBestScoredMoveUpToLimitConsideringCommunication(
            IReadOnlyCollection <int> cardsInHand, PlayerInformation info)
        {
            var spm   = new ScorePlayerPlays();
            var plays = spm.GetScoredPlays(cardsInHand, info.RowsOfCards);

            if (plays.Count == 0)
            {
                return(new PlayerMove(PlayerMoveDecision.Undecided));
            }

            ConsiderCommunication(info, plays);

            var bestMove = PlayerRulesUtils.GetBestMoveFromPlays(plays);

            if (bestMove.score <= MaxDistanceForSingleScoredMoveWithCommunicationAndTwoCardsToPlay &&
                info.CardsToPlayThisTurn == 2 ||
                bestMove.score <= MaxDistanceForSingleScoredMoveWithCommunicationAndOneCardToPlay &&
                info.CardsToPlayThisTurn == 1)
            {
                return(new PlayerMove(PlayerMoveDecision.WantToPlay, bestMove.placements[0]));
            }

            return(new PlayerMove(PlayerMoveDecision.Undecided));
        }
 void Start()
 {
     rigid = GetComponent<Rigidbody>();
     playerInformation = GetComponent<PlayerInformation>();
     cameraController = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraController>();
     StartCoroutine(PointToMouse());
 }
Esempio n. 8
0
        public Player(World world, PlayerInformation playerInfo)
            : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0)
        {
            this.playerInfo = playerInfo;

            World.ServerLink.MessageReceivedEvent += HandleReceivedMessage;
        }
Esempio n. 9
0
    /***********Left-Role部分end*************/

    private void Awake()
    {
        playInfo  = PlayerInformation._instance;
        _Instance = this;

        /***********Left-Role部分*************/
        #region Left-Role部分
        Left_Role  = transform;
        playerName = Left_Role.Find("label-player-name").GetComponent <UILabel>();
        //装备
        HelmSpire      = Left_Role.Find("HelmSpire").GetComponent <UISprite>();
        ClothSpire     = Left_Role.Find("ClothSpire").GetComponent <UISprite>();
        WeaponSprite   = Left_Role.Find("WeaponSprite").GetComponent <UISprite>();
        ShoesSprite    = Left_Role.Find("ShoesSprite").GetComponent <UISprite>();
        NecklaceSprite = Left_Role.Find("NecklaceSprite").GetComponent <UISprite>();
        BraceleSprite  = Left_Role.Find("BraceleSprite").GetComponent <UISprite>();
        RingSprite     = Left_Role.Find("RingSprite").GetComponent <UISprite>();
        WingSprite     = Left_Role.Find("WingSprite").GetComponent <UISprite>();
        //数值
        // Hpnumber= Left_Role.Find("life-number").GetComponent<UISprite>();
        HpLabel = Left_Role.Find("life-number/Label").GetComponent <UILabel>();
        // damage_number = Left_Role.Find("damage-number ").GetComponent<UISprite>();
        damage_label = Left_Role.Find("damage-number/Label").GetComponent <UILabel>();
        Expnumber    = Left_Role.Find("exp-bg/exp").GetComponent <UISlider>();
        ExpLabel     = Left_Role.Find("exp-bg/exp/Label").GetComponent <UILabel>();
        #endregion
        /***********Left-Role部分end*************/
    }
Esempio n. 10
0
    public EnterWorldRequest(GameClient client, ReceivablePacket packet)
    {
        // Read data.
        string characterName = packet.ReadString();

        // Create a new PlayerInstance.
        Player player = new Player(client, characterName);

        // Add object to the world.
        WorldManager.AddObject(player);
        // Assign this player to client.
        client.SetActiveChar(player);
        // Send active player information to client.
        client.ChannelSend(new EnterWorldInformation(player));
        // Send and receive visible object information.
        PlayerInformation playerInfo = new PlayerInformation(player);

        foreach (Player nearby in WorldManager.GetVisiblePlayers(player))
        {
            // Send the information to the current player.
            client.ChannelSend(new PlayerInformation(nearby));
            // Send information to the other player as well.
            nearby.ChannelSend(playerInfo);
        }
    }
Esempio n. 11
0
        void HandlePlayerJoinedS2Evt(SFMessage message)
        {
            UInt64            GameInsID    = message.GetValue <UInt64>("GameInsUID");
            PlayerInformation JoinedPlayer = message.GetValue <PlayerInformation>("JoinedPlayer");

            PrintStatus(1, "HandlePlayerJoinedS2Evt  GameInsID = {0} MyID  = {1} JoinedPlayerID = {2} ",
                        GameInsID, m_LoginID, JoinedPlayer.PlayerID);

            //variableBuilder.SetVariable("GameInsUID", parser.GetGameInsUID());
            //variableBuilder.SetVariable("JoinedPlayer", parser.GetJoinedPlayer());
            //variableBuilder.SetVariable("JoinedPlayerRole", parser.GetJoinedPlayerRole());
            //variableBuilder.SetVariable("JoinedPlayerDead", parser.GetJoinedPlayerDead());
            //variableBuilder.SetVariable("JoinedPlayerIndex", parser.GetJoinedPlayerIndex());
            //variableBuilder.SetVariable("JoinedPlayerCharacter", parser.GetJoinedPlayerCharacter());
            if (m_MatchedInfo == null || m_Game == null)
            {
                return;
            }

            if (m_MatchedInfo.mJoinedGameID != GameInsID)
            {
                return;
            }

            m_MatchedInfo.mOtherPlayers.Add(JoinedPlayer.PlayerID);

            if (Is4xComplte())
            {
                if (m4xMatchedAction != null)
                {
                    m4xMatchedAction(this);
                }
            }
        }
Esempio n. 12
0
    private void Awake()
    {
        _equipPopInstance = this;
        euqSpirte         = transform.Find("euqBg/euq").GetComponent <UISprite>();
        //是否已经装备上了
        aly_euq       = transform.Find("euqBg/aly-euq").GetComponent <UISprite>();
        grid          = transform.Find("euqBg/stars-Scroll-View/Grid").GetComponent <UIGrid>();
        LabelEquName  = transform.Find("Label-equName").GetComponent <UILabel>();
        LabelQuality  = transform.Find("Label-quality").GetComponent <UILabel>();
        LabelDamage   = transform.Find("Label-damage").GetComponent <UILabel>();
        LabelLife     = transform.Find("Label-life").GetComponent <UILabel>();
        LabelPower    = transform.Find("Label-power").GetComponent <UILabel>();
        LabelDescribe = transform.Find("Label-Describe").GetComponent <UILabel>();
        LabelLevel    = transform.Find("Label-Level").GetComponent <UILabel>();


        btnEuqOk         = transform.Find("btn-euq-ok").GetComponent <UIButton>();
        btnEuqLevelUp    = transform.Find("btn-euq-level").GetComponent <UIButton>();
        btn_close_euq    = transform.Find("btn-close-euq").GetComponent <UIButton>();
        btnEqupUninstall = transform.Find("btn-euq-uninstall").GetComponent <UIButton>();


        transform.GetComponent <TweenScale>().PlayReverse();
        btn_close_euq.onClick.Add(new EventDelegate(this, "ClosePopPanel"));
        //点击穿上装备的按你要
        btnEuqOk.onClick.Add(new EventDelegate(this, "PutThisEqupForPlayer"));
        //升级装备
        btnEuqLevelUp.onClick.Add(new EventDelegate(this, "EqupLevelUp"));
        //卸载装备
        btnEqupUninstall.onClick.Add(new EventDelegate(this, "PutOFFThisEqupForPlayer"));
        PlayInfo = PlayerInformation._instance;
    }
    // Use this for initialization
    void Start()
    {
        _screenHSize = Screen.height;
        _screenWsize = Screen.width;
        GUITexture GameSetting = FindObjectOfType(typeof(GUITexture)) as GUITexture;

        if (GameSetting.name == "Main Camera")
        {
            GameSetting.transform.position   = Vector3.zero;
            GameSetting.transform.localScale = Vector3.zero;
            GameSetting.pixelInset           = new Rect(0, 0, _screenWsize, _screenHSize);
        }

        GameObject player = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) as GameObject;

        player.name = "player";

        _playerInformation = new PlayerInformation();
        _playerInformation.Awake();

        for (int i = 0; i < Enum.GetValues(typeof(AttributeName)).Length; i++)
        {
            _playerInformation.GetPrimaryAttribute(i).BaseValue = STARTING_VALUE;
        }

        _playerInformation.StatUpdate();
    }
        public static void setPlayerInPositionInPodium(int positionIn, PlayerInformation p)
        {
            string allCodifyInfo = codifyPlayer(p);
            string pNickName     = p.pNick;

            // Compruebo si ya existe el nick (si existe, añadir ~! al final).
            while (PlayerPrefs.HasKey(pNickName))
            {
                pNickName = pNickName + "~!";
            }

            // Borro el player que está en la última posición (10) y desplazo a todos los players más abajo de la posición positionIn.
            if (PlayerPrefs.HasKey("pos10"))
            {
                PlayerPrefs.DeleteKey(PlayerPrefs.GetString("pos10"));
            }

            for (int i = 9; i >= positionIn; i--)
            {
                string nickToDownPosition = PlayerPrefs.GetString("pos" + i);
                PlayerPrefs.SetString("pos" + (i + 1), nickToDownPosition);
            }

            // Colocamos el player en la posición ya libre.
            PlayerPrefs.SetString("pos" + positionIn, pNickName);
            PlayerPrefs.SetString(pNickName, allCodifyInfo);
        }
Esempio n. 15
0
    public static void SetScore(int newScore, bool isHard)
    {
        if (isHard)
        {
            DatabaseReference reference = PlayerInformation.GetDatabaseReference()
                                          .Child("user")
                                          .Child(PlayerInformation.auth.CurrentUser.UserId)
                                          .Child("score");

            Score  score     = new Score(newScore, GetTimestamp());
            string jsonScore = JsonUtility.ToJson(score);

            reference.SetRawJsonValueAsync(jsonScore);
        }
        else
        {
            DatabaseReference reference = PlayerInformation.GetDatabaseReference()
                                          .Child("user")
                                          .Child(PlayerInformation.auth.CurrentUser.UserId);

            EasyScore easyScore     = new EasyScore(newScore, GetTimestamp());
            string    jsonEasyScore = JsonUtility.ToJson(easyScore);

            reference.Child("easyScore").SetRawJsonValueAsync(jsonEasyScore);
        }
    }
Esempio n. 16
0
    /// <summary>
    /// Gets the left stick axis.
    /// </summary>
    /// <returns>The left stick axis.</returns>
    /// <param name="iPlayerInformation">player information.</param>
    public Vector3 GetLeftStickAxis(PlayerInformation iPlayerInformation)
    {
        float tHorizontalInput = iPlayerInformation.PlayerState.ThumbSticks.Left.X;
        float tVerticalInput   = iPlayerInformation.PlayerState.ThumbSticks.Left.Y;

        return(new Vector3(tHorizontalInput, 0, tVerticalInput));
    }
Esempio n. 17
0
    public static void UpdateMoney(int amount)
    {
        DatabaseReference reference = PlayerInformation.GetDatabaseReference()
                                      .Child("user")
                                      //.Child("pnRD68Js9kU5O4UNvRaPcoueTsy2")
                                      .Child(PlayerInformation.auth.CurrentUser.UserId)
                                      .Child("money");

        reference.GetValueAsync().ContinueWith(task =>
        {
            if (task.IsCompleted)
            {
                // Read
                DataSnapshot snapshot       = task.Result;
                IDictionary data            = (IDictionary)snapshot.Value;
                string dataMoney            = data["money"].ToString();
                int tmpMoney                = int.Parse(dataMoney);
                int finalAmount             = amount + tmpMoney;
                PlayerInformation.SoulMoney = finalAmount;

                // Write
                SoulMoney soulMoney = new SoulMoney(PlayerInformation.SoulMoney);
                string json         = JsonUtility.ToJson(soulMoney);
                reference.SetRawJsonValueAsync(json);

                // Achievement
                PlayerInformation.AchievementSoul();
            }
        });
    }
Esempio n. 18
0
 void Start()
 {
     _playerInfo = GameObject.FindGameObjectWithTag(Tags.PLAYERINFO).GetComponent <PlayerInformation>();
     _save       = GameObject.FindGameObjectWithTag(Tags.SAVELOADOBJECT).GetComponent <SaveLoadGame>();
     _gender     = GetComponent <ChoosePlayerGender>();
     _name       = GetComponent <ChoosePlayerName>();
 }
Esempio n. 19
0
    /// <summary>
    /// Gets the button pressed.
    /// </summary>
    /// <returns><c>true</c>, if button pressed was gotten, <c>false</c> otherwise.</returns>
    /// <param name="iPlayerInformation">player information.</param>
    /// <param name="iButton">button.</param>
    public bool GetButtonPressed(PlayerInformation iPlayerInformation, ButtonType iButton)
    {
        switch (iButton)
        {
        case ButtonType.BUTTON_A:
            return(iPlayerInformation.PlayerState.Buttons.A.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_B:
            return(iPlayerInformation.PlayerState.Buttons.B.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_X:
            return(iPlayerInformation.PlayerState.Buttons.X.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_Y:
            return(iPlayerInformation.PlayerState.Buttons.Y.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_START:
            return(iPlayerInformation.PlayerState.Buttons.Start.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_SELECT:
            return(iPlayerInformation.PlayerState.Buttons.Guide.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_LB:
            return(iPlayerInformation.PlayerState.Buttons.LeftShoulder.Equals(ButtonState.Pressed));

        case ButtonType.BUTTON_RB:
            return(iPlayerInformation.PlayerState.Buttons.RightShoulder.Equals(ButtonState.Pressed));
        }

        return(false);
    }
Esempio n. 20
0
    /// <summary>
    /// 初始化组件对象
    /// </summary>
    private void Awake()
    {
        headSprite    = transform.Find("player-head").GetComponent <UISprite>();
        headSpriteBtn = headSprite.transform.GetComponent <UIButton>();

        playerLabelName = transform.Find("player-label-name").GetComponent <UILabel>();
        playerLabelLv   = transform.Find("player-label-lv").GetComponent <UILabel>();
        playerHp        = transform.Find("player-hp-bloodbar").GetComponent <UISlider>();
        labelHpBar      = transform.Find("player-hp-bloodbar/label-hpbar").GetComponent <UILabel>();

        playerSp   = transform.Find("player-sp-spbar").GetComponent <UISlider>();
        labelSpBar = transform.Find("player-sp-spbar/label-sppbar").GetComponent <UILabel>();

        btnAddHp = transform.Find("player-btn-addhp").GetComponent <UIButton>();
        btnAddSp = transform.Find("player-btn-addmp").GetComponent <UIButton>();

        playerInfo = PlayerInformation._instance;

        //注册事件   这里需要  PlayerInformation比这个类先执行  这样  info的awake方法比他的先执行,那么这里才可以获取实例
        //当然  也可以在start中写  但是 PlayerInformation比这个类先执行  在edit/scpript Execution Order中设置
        PlayerInformation._instance.OnPlayInfoChanged += OnPlayerInfoChanged;


        //头像的点击事件委托
        EventDelegate eventD = new EventDelegate(this, "OnSpireHeadClick");

        //为事件添加委托
        headSpriteBtn.onClick.Add(eventD);
    }
Esempio n. 21
0
    private void Awake()
    {
        playInfo      = PlayerInformation._instance;
        packageSystem = PlayerPackageSystem._Instance;
        tweenPos      = GetComponent <TweenScale>();

        btn_battle  = transform.Find("btn-battle").GetComponent <UIButton>();
        btn_Package = transform.Find("btn-package").GetComponent <UIButton>();
        btn_skill   = transform.Find("btn-skill").GetComponent <UIButton>();
        btn_mission = transform.Find("btn-mission").GetComponent <UIButton>();
        btn_shop    = transform.Find("btn-shop").GetComponent <UIButton>();
        btn_system  = transform.Find("btn-system").GetComponent <UIButton>();
        //玩家基础信息的监听
        playInfo.OnPlayInfoChanged += OnPlayInfoChanged;


        EventDelegate packageEvent = new EventDelegate(this, "OpenPackage");

        btn_Package.onClick.Add(packageEvent);

        //查看我的任务(当前玩家已经领取的任务)
        btn_mission.onClick.Add(new EventDelegate(this, "OpenTaskList"));

        btn_battle.onClick.Add(new EventDelegate(this, "OpenBattlePanel"));
        btn_skill.onClick.Add(new EventDelegate(this, "OpenSkillPanel"));
        btn_system.onClick.Add(new EventDelegate(this, "OpenSystemPanel"));

        btn_shop.onClick.Add(new EventDelegate(this, "OpenShopePanel"));
        tweenPos.PlayReverse();
    }
Esempio n. 22
0
        public void PlayBestScoredMoveConsideringCommunication_CommunicationBlocksTwoPlays_PlayOverallBestPlay()
        {
            // 29 - 39 on 30 is blocked, but still the best
            // 61 on 80 is less good
            // 8 on 2 is blocked
            var cards = new ReadOnlyCollection <int>(new List <int> {
                39, 29, 61, 8
            });
            var rows = TestHelper.GetPreparedRows(30, 2, 99, 80);
            var comm = new List <(int, PlayerCommunication)>
            {
                (1,
                 new PlayerCommunication(RowOfCardsIdentifier.FirstRowUp,
                                         PlayerCommunicationType.DoNotPlayHere)),
                (1,
                 new PlayerCommunication(RowOfCardsIdentifier.SecondRowDown,
                                         PlayerCommunicationType.TryNotToPlayHere)),
                (1,
                 new PlayerCommunication(RowOfCardsIdentifier.SecondRowUp,
                                         PlayerCommunicationType.DoNotPlayHere))
            };
            var info = new PlayerInformation(0, 2, rows, comm);

            var expectedMove = new PlayerMove(PlayerMoveDecision.WantToPlay,
                                              new CardPlacement(RowOfCardsIdentifier.FirstRowUp, 39));

            var move = PlayerMoveRules.PlayBestScoredMoveConsideringCommunication(cards, info);

            Assert.That(move, Is.EqualTo(expectedMove));
        }
 public virtual void Awake()
 {
     bi = this.gameObject.GetComponent<BuildingInformation>();
     nsb = this.gameObject.GetComponent<NormalStateBuild>();
     playerInfo = GameObject.Find("GameContent").GetComponent<PlayerInformation>();
     adjustTimeBaseOnLevel();
 }
Esempio n. 24
0
        PlayBestScoredMoveWithScoreChangeUpToLimitConsideringCommunication_PlayCardsBetweenBackwardsTrickCards_PlaysIt()
        {
            // 4, 12, 2 is better than 12, 2, 4
            var cards = new ReadOnlyCollection <int>(new List <int> {
                2, 4, 12, 13
            });
            var rows = TestHelper.GetPreparedRows(1, 80, 75, 78);
            var comm = new List <(int, PlayerCommunication)>();
            var info = new PlayerInformation(0, 2, rows, comm);

            var expectedMove = new PlayerMove(PlayerMoveDecision.WantToPlay,
                                              new CardPlacement(RowOfCardsIdentifier.FirstRowUp, 4));

            var move = PlayerMoveRules.PlayBestScoredMoveUpToLimitConsideringCommunication(cards, info);

            Assert.That(move, Is.EqualTo(expectedMove));

            cards = new ReadOnlyCollection <int>(new List <int> {
                2, 12, 13
            });
            rows         = TestHelper.GetPreparedRows(4, 80, 75, 78);
            comm         = new List <(int, PlayerCommunication)>();
            info         = new PlayerInformation(1, 2, rows, comm);
            expectedMove = new PlayerMove(PlayerMoveDecision.WantToPlay,
                                          new CardPlacement(RowOfCardsIdentifier.FirstRowUp, 12));

            move = PlayerMoveRules.PlayBestScoredMoveUpToLimitConsideringCommunication(cards, info);

            Assert.That(move, Is.EqualTo(expectedMove));
        }
Esempio n. 25
0
        PlayBestScoredMoveWithScoreChangeUpToLimitConsideringCommunication_CommunicationBlocksTwoPlays_PlayRemainingPlay()
        {
            // 28 - 38 on 30 is blocked
            // 76 on 80 is blocked
            // 8 on 2 is played
            var cards = new ReadOnlyCollection <int>(new List <int> {
                38, 28, 76, 8
            });
            var rows = TestHelper.GetPreparedRows(30, 2, 99, 80);
            var comm = new List <(int, PlayerCommunication)>
            {
                (1,
                 new PlayerCommunication(RowOfCardsIdentifier.FirstRowUp,
                                         PlayerCommunicationType.DoNotPlayHere)),
                (1,
                 new PlayerCommunication(RowOfCardsIdentifier.SecondRowDown,
                                         PlayerCommunicationType.TryNotToPlayHere))
            };
            var info = new PlayerInformation(0, 2, rows, comm);

            var expectedMove = new PlayerMove(PlayerMoveDecision.WantToPlay,
                                              new CardPlacement(RowOfCardsIdentifier.SecondRowUp, 8));

            var move = PlayerMoveRules.PlayBestScoredMoveUpToLimitConsideringCommunication(cards, info);

            Assert.That(move, Is.EqualTo(expectedMove));
        }
    private void OnEnable()
    {
        character  = target as CharacterInformation;
        enemy      = target as EnemyInformation;
        NPC        = target as NPCInformation;
        player     = target as PlayerInformation;
        characters = Resources.LoadAll <CharacterInformation>("Configuration");
        _ID        = serializedObject.FindProperty("_ID");
        _name      = serializedObject.FindProperty("_name");
        SMParams   = serializedObject.FindProperty("_SMParams");
        attribute  = serializedObject.FindProperty("attribute");
        attrDrawer = new RoleAttributeGroupDrawer(serializedObject, attribute, lineHeight, lineHeightSpace);

        lineHeight      = EditorGUIUtility.singleLineHeight;
        lineHeightSpace = lineHeight + 2;

        if (enemy)
        {
            EnemyInfoEnable();
        }
        else if (NPC)
        {
            NPCInfoEnable();
        }
        else if (player)
        {
            backpack = serializedObject.FindProperty("backpack");
        }
    }
    public string[] SetNames()
    {
        int index = 0;

        /*Debug.Log("dino tracking script");
         * Debug.Log(dinoTrackingScript);*/

        //int playerNum = dinoTrackingScript.playerNum;


        while (index < playerNames.Length)
        {
            playerNames[index] = "CPU " + index;
            playerNamesObjs[index].guiText.text = playerNames[index];

            index++;
        }

        if (Network.isServer)
        {
            PlayerInformation[] infoArr = new PlayerInformation[4];

            networkHandler.playerInformation.Values.CopyTo(infoArr, 0);

            for (int i = 0; i < infoArr.Length; i++)
            {
                if (infoArr[i] != null)
                {
                    netView.RPC("AddName", RPCMode.AllBuffered, infoArr[i].playerName, i);
                }
            }
        }

        return(playerNames);
    }
        private void CmdRemoveGroup(IPlayer player, string cmd, string[] args)
        {
            if (args.Length != 2)
            {
                player.Reply(GetMessage("Syntax : removegroup", player.Id));
                return;
            }

            IPlayer target = FindPlayer(args[0], player);

            if (target == null)
            {
                return;
            }

            PlayerInformation information = PlayerInformation.Get(target.Id);

            if (information == null || !information.Groups.Any(p => p.Value == args[1].ToLower()))
            {
                player.Reply(GetMessage("User Isn't In Group", player.Id).Replace("{target}", target.Name).Replace("{group}", args[1].ToLower()));
                return;
            }

            information.RemoveGroup(args[1].ToLower());
        }
        private void CmdPlayerInfo(IPlayer player, string cmd, string[] args)
        {
            IPlayer target;

            if (args.Length == 0 || !player.HasPermission(AdminPermission))
            {
                target = player;
            }
            else
            {
                target = FindPlayer(args[0], player);
            }

            if (target == null)
            {
                return;
            }

            var information = PlayerInformation.Get(target.Id);

            if (information == null)
            {
                player.Reply(GetMessage("Player Has No Info", player.Id));
            }
            else
            {
                string msg = GetMessage("Player Info", player.Id);

                msg = msg.Replace("{player}", $"{information.Name} ({information.Id})");
                msg = msg.Replace("{groups}", string.Join(", ", (from g in information.Groups select $"{g.Value} until {g.ExpireDate.ToLongDateString() + " " + g.ExpireDate.ToShortTimeString()} UTC").ToArray()));
                msg = msg.Replace("{permissions}", string.Join(", ", (from p in information.Permissions select $"{p.Value} until {p.ExpireDate.ToLongDateString() + " " + p.ExpireDate.ToShortTimeString()} UTC").ToArray()));

                player.Reply(msg);
            }
        }
        private void CmdRevokePerm(IPlayer player, string cmd, string[] args)
        {
            if (args.Length != 2)
            {
                player.Reply(GetMessage("Syntax : revokeperm", player.Id));
                return;
            }

            IPlayer target = FindPlayer(args[0], player);

            if (target == null)
            {
                return;
            }

            PlayerInformation information = PlayerInformation.Get(target.Id);

            if (information == null || !information.Permissions.Any(p => p.Value == args[1].ToLower()))
            {
                player.Reply(GetMessage("User Doesn't Have Permission", player.Id).Replace("{target}", target.Name).Replace("{permission}", args[1].ToLower()));
                return;
            }

            information.RemovePermission(args[1].ToLower());
        }
Esempio n. 31
0
 private void OnEnemyKilled(EnemyKillEventArgs args)
 {
     killCount++;
     Credits += args.Enemy.MaxHealth;
     UpdateUi(transform);
     PlayerInformation.UpdateStats();
 }
Esempio n. 32
0
        public void PlayerCreated(object sender, PlayerCreatedEventArgs pcea)
        {
            Peer peer     = (Peer)sender;
            int  playerID = pcea.Message.PlayerID;
            PlayerInformation playerInfo = peer.GetPeerInformation(playerID);

            // See if the player that was just created is us
            if (playerInfo.Local)
            {
                localPlayer.ID   = playerID;
                localPlayer.Name = playerInfo.Name;
            }
            // If not, create a remote player
            else
            {
                Ship newShip = new Ship(this);
                newShip.HostName     = playerInfo.Name.ToUpper();
                newShip.State        = (int)ShipState.Normal;
                newShip.ScreenBounds = this.windowBounds;
                RemotePlayer newPlayer = new RemotePlayer(playerID, playerInfo.Name, newShip);
                lock (otherPlayers) {
                    otherPlayers.Add(playerID, newPlayer);
                }
            }
        }
        void OnTriggerEnter2D(Collider2D objectHit)
        {
            if (!isInvincible)
            {
                //If it hit a bullet
                if (objectHit.gameObject.GetComponent <BulletController>())
                {
                    //Take damage and check if he died
                    PlayerInformation.GetInstance().DecreasePlayerHealth();

                    AudioManager.GetInstance().SlimeDamageSound();

                    //Update UI
                    playerHeartsArray.UpdateUIPlayer(PlayerInformation.GetInstance().health);
                    if (isTaunting)
                    {
                        anim.SetTrigger("PlayerTauntHurtAnimTrigger");
                    }
                    else
                    {
                        anim.SetTrigger("PlayerStillHurtAnimTrigger");
                    }

                    //--health;
                    if (PlayerInformation.GetInstance().health <= 0)
                    {
                        Died();
                    }

                    StartCoroutine(Invincibility());
                }
            }
        }
Esempio n. 34
0
        public Player(World world, PlayerInformation playerInfo)
            : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0)
        {
            this.playerInfo = playerInfo;
            this.Score = new Score(); //Gives scoreHUD a valid reference to start with

            World.ServerLink.MessageReceivedEvent += HandleReceivedMessage;
        }
Esempio n. 35
0
        public RemotePlayer(World world, PlayerInformation playerInfo)
            : base(world, playerInfo)
        {
            this.lastMsgUpdate = new TimeSpan();

            // set our update frequency
            this.msgUpdateFrequency = new TimeSpan(0, 0, 0, 0, (int)(1000 / (UInt16)World.VarDB["updatesPerSecond"].Value));
        }
 public void MyPosition()
 {
     RectTransform rect = this.GetComponent<RectTransform>();
     playerInformation =
         GameObject.Find("ShogiInfoGetter").GetComponent<PlayerInformation>();
     rect.localPosition = new Vector3(CalcPosX(posx), CalcPosY(posy), 0f);
     if(owner.Equals(playerInformation.last_player["user_id"])){
         rect.localRotation = Quaternion.Euler(0, 0, 180);
     }
 }
Esempio n. 37
0
        public LocalPlayer(World world, PlayerInformation playerInfo)
            : base(world, playerInfo)
        {
            // set our update frequency
            this.msgUpdateFrequency = new TimeSpan(0, 0, 0, 0, (int)(1000 / (UInt16)World.VarDB["updatesPerSecond"].Value));

            // TODO support if these variables change
            this.maxVelocity = (Single)World.VarDB["tankSpeed"].Value;
            this.maxAngularVelocity = (Single)World.VarDB["tankAngVel"].Value;
        }
Esempio n. 38
0
 //public BaseGameObject selectedObject;
 void Awake()
 {
     avatarObject = GameObject.FindGameObjectWithTag("Player");
     avatar = avatarObject.GetComponent<Avatar>();
     DontDestroyOnLoad(gameObject);
     Hero = new PlayerInformation();
     SaveLoad.content = new SavedContent();
     Hero.StartNewGame();
     //ChangeMinimap(false);
     //gameObject.AddComponent<GUIScale>();
 }
Esempio n. 39
0
        public LocalPlayer(World world, PlayerInformation playerInfo)
            : base(world, playerInfo)
        {
            // set our update frequency
            this.msgUpdateFrequency = new TimeSpan(0, 0, 0, 0, (int)(1000 / (UInt16)World.VarDB["updatesPerSecond"].Value));

            // TODO support if these variables change
            this.maxVelocity = (Single)World.VarDB["tankSpeed"].Value;
            this.maxAngularVelocity = (Single)World.VarDB["tankAngVel"].Value;

            inputService = (IInputService)World.IService.GetService(typeof(IInputService));
            inputService.GetKeyboard().KeyPressed += KeyPressed;
        }
Esempio n. 40
0
        public Player(GameKeeper gameKeeper, Byte slot, NetConnection connection, PlayerInformation playerInfo)
        {
            this.Slot       = slot;
            this.Connection = connection;
            this.Team       = playerInfo.Team;
            this.Callsign   = playerInfo.Callsign;
            this.Tag        = playerInfo.Tag;

            this.gameKeeper = gameKeeper;

            this.playerState = PlayerState.Joining;

            Log.InfoFormat("Player #{0} \"{1}\" <{2}> created and joined to {3}", Slot, Callsign, Tag, Team);
        }
Esempio n. 41
0
        public Player(World world, PlayerInformation playerInfo)
            : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0)
        {
            this.playerInfo = playerInfo;
            this.Score = new Score(); //Gives scoreHUD a valid reference to start with

            explosion = new AnimatedSprite(World,
                                           World.Content.Load<Texture2D>("textures/bz/explode1"),
                                           Position,
                                           GetTankSize(World, PlayerInfo) * 4,
                                           Rotation,
                                           new Point(8, 8), new Point(64, 64), SpriteSheetDirection.RightToLeft, false);

            explosion.Running = false;

            World.ServerLink.MessageReceivedEvent += HandleReceivedMessage;
        }
    // Use this for initialization
    void Start()
    {
        wrapper = GameObject.Find ("Wrapper").GetComponent<Wrapper> ();
        userManager = GameObject.Find("UserManager").GetComponent<UserManager>();
        loginManager = GameObject.Find("LoginManager").GetComponent<LoginManager>();
        komaGenerator = GameObject.Find("KomaGenerator").GetComponent<KomaGenerator>();

        playerInfo = this.GetComponent<PlayerInformation>();
        playInfo = this.GetComponent<PlayingInformation>();

        UsersURL = "http://" + loginManager.GetURL()
            + "/plays/" + userManager.play_id.ToString() + "/users";
        PlayURL = "http://" + loginManager.GetURL()
            + "/plays/" + userManager.play_id.ToString();
        Debug.Log (UsersURL);
        Debug.Log (PlayURL);

        UsersInfoGet ();
        PlayInfoGet ();
    }
    // Use this for initialization
    void Start()
    {
        Respawner = this;
        info = PlayerInformation.player_information;
        playersToRespawn = new List<bool>();
        for (int i = 0; i < info.players.Count; i++)
        {
            playersToRespawn.Add(false);
        }
        respawnTimers = new List<float>();

        for (int i = 0; i < info.players.Count; i++)
        {
            respawnTimers.Add(0);
        }

        players = new List<PlatformerCharacter2D>();
        for (int i = 0; i < info.players.Count; i++)
        {
            players.Add(info.players[i]);
        }
    }
    // Use this for initialization
    public void Start()
    {
        info = new PlayerInformation();
        info.Awake();
        chars = new CharacterGen();
        enemyTypeNumber =0;
        playerNumber =1;
        for (int i = 0; i < Enum.GetValues(typeof(AttributeName)).Length; i++) {
            info.GetPrimaryAttribute (i).BaseValue = chars.STARTING_VALUE;
        }
        characterName = String.Empty;
        itemAmount = 0;
        _primaryAttribute = new string[info._primaryAttribute.Length];
        _primaryAttributeValues=new int[info._primaryAttribute.Length];
        _vital = new string[info._vital.Length];
        _vitalValue=new int[info._vital.Length];
        _mana = new string[info._mana.Length];
        _manaValue=new int[info._mana.Length];
        _attack = new string[info._attack.Length];
        _attackValue = new int[info._attack.Length];
        _defence = new string[info._defence.Length];
        _defenceValue = new int[info._defence.Length];
        moneyTotal=0;
        money = new MoneySystem();
        itemsNameArray = new ArrayList();
        itemsContentArray = new ArrayList();
        experience =100;

        nextLevelvalue = experience*1.2f;
        nextLevel = (int)(experience*1.2f);
        level =1;
        initiliseConstantVariables();

        playerPos = GameObject.FindGameObjectWithTag("Player");
        if(playerPos!=null)
            positionOnScreen= playerPos.transform.position;

        if(PlayerPrefs.GetString ("Player Name")!= ""){
            LoadData();
        }
    }
Esempio n. 45
0
 /// <summary>
 /// Adds a new remote player.
 /// </summary>
 /// <param name="playerInfo"></param>
 public void AddPlayer(PlayerInformation playerInfo)
 {
     // add player to our list
     remotePlayers[playerInfo.Slot] = new RemotePlayer(world, playerInfo);
 }
    /// <summary>
    /// Set the user information 
    /// </summary>
    public void SetUserInfo()
    {
        //Before we call host, let's actually call SetPeerInformation
        PlayerInformation myinformation = new PlayerInformation();
        myinformation.Name = username;

        peerObject.SetPeerInformation(myinformation, SyncFlags.PeerInformation);
    }
Esempio n. 47
0
 public void AddPlayerInformation(PlayerInformation player)
 {
     players.Add(player);
 }
Esempio n. 48
0
 void Start()
 {
     playerInfo = GameObject.Find("GameContent").GetComponent<PlayerInformation>();
 }
Esempio n. 49
0
        /// <summary>
        /// Attempts to find a slot to allocate a <see cref="Player"/>.
        /// </summary>
        /// <param name="playerAdding"><see cref="PlayerInformation"/> about the player being added.</param>
        /// <param name="denyReason"><see cref="String"/> to be populated with a reason if a slot can not be allocated.</param>
        /// <returns><see cref="ProtocolInformation.DummySlot"/> if a slot can't be allocated, otherwise the slot.</returns>
        private Byte AllocateSlot(PlayerInformation playerAdding, out String denyReason)
        {
            Player player;
            Byte earliestSlot = ProtocolInformation.DummySlot;

            for (Byte i = 0; i < ProtocolInformation.MaxPlayers; ++i)
            {
                // we found a player at this slot
                if (players.TryGetValue(i, out player))
                {
                    // check if they're the same callsign
                    if (playerAdding.Callsign == player.Callsign)
                    {
                        // found a duplicate callsign, no good
                        denyReason = "callsign is already in use";
                        return ProtocolInformation.DummySlot;
                    }
                }
                else
                {
                    // we didn't find a player at i, so let's save this slot in case we make it out of this loop
                    if (i < earliestSlot)
                        earliestSlot = i;
                }
            }

            // we didn't find an open slot since it's still at dummy slot...
            if (earliestSlot == ProtocolInformation.DummySlot)
            {
                denyReason = "the game is full";
                return ProtocolInformation.DummySlot;
            }

            denyReason = null;
            return earliestSlot;
        }
Esempio n. 50
0
 //public static GeneralData Data;
 
 //public Texture cursorImage;
 
 //public float effectTimer;
    //private float checkTimer;

    //public BaseGameObject selectedObject;


    void Awake()
    {
        if(Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(this);
        Hero = new PlayerInformation();
		Debug.Log("new hero");
        SaveLoad.content = new SavedContent();
    }
Esempio n. 51
0
 protected static Vector2 GetTankSize(World world, PlayerInformation playerInfo)
 {
     // TODO get size from variable database
     return new Vector2(4.86f, 6);
 }
Esempio n. 52
0
 // Use this for initialization
 public virtual void Awake()
 {
     playerInfo = GameObject.Find("GameContent").GetComponent<PlayerInformation>();
     bi = this.GetComponent<BuildingInformation>();
 }
Esempio n. 53
0
 protected static Texture2D GetTexture(World world, PlayerInformation playerInfo)
 {
     try
     {
         return world.Content.Load<Texture2D>(String.Format("textures/tank_{0}", ProtocolHelpers.TeamTypeToName(playerInfo.Team)));
     }
     catch (ContentLoadException e)
     {
         Log.Error(e.Message);
         Log.Error(e.StackTrace);
         return world.Content.Load<Texture2D>("textures/tank_white");
     }
 }
 void Start()
 {
     playerInformtion = GetComponent<PlayerInformation>();
     lineRenderer = GetComponent<LineRenderer>();
     lineRenderer.SetVertexCount(BounceLimit);
 }
Esempio n. 55
0
 protected static Vector2 GetTankSize(World world, PlayerInformation playerInfo)
 {
     return new Vector2((Single)world.VarDB["tankWidth"].Value,
                        (Single)world.VarDB["tankLength"].Value);
 }
Esempio n. 56
0
        private static void AppLoop()
        {
            NetIncomingMessage msg;
            
            while (true)
            {
                if ((msg = server.ReadMessage()) != null)
                {
                    switch (msg.MessageType)
                    {
                        case NetIncomingMessageType.WarningMessage:
                            Log.Warn(msg.ReadString());
                            break;

                        case NetIncomingMessageType.ErrorMessage:
                            Log.Error(msg.ReadString());
                            break;

                        case NetIncomingMessageType.DebugMessage:
                            Log.Debug(msg.ReadString());
                            break;

                        case NetIncomingMessageType.DiscoveryRequest:
                            break;

                        case NetIncomingMessageType.StatusChanged:
                            {
                                // we're not interested in status changes on the server yet
                                if (msg.SenderConnection == null)
                                    break;

                                gameKeeper.HandleStatusChange(msg);

                                break;
                            }

                        case NetIncomingMessageType.ConnectionApproval:
                            {
                                // chop off header
                                MessageType messageType = (MessageType)msg.ReadByte();

                                // WTF?
                                if (messageType != MessageType.MsgEnter)
                                {
                                    String rejection = String.Format("message type not as expected (expected {0}, you sent {1})",
                                                                     MessageType.MsgEnter, messageType);
                                    msg.SenderConnection.Deny(rejection);
                                    break;
                                }

                                UInt16 clientProtoVersion = msg.ReadUInt16();

                                if (clientProtoVersion != ProtocolInformation.ProtocolVersion)
                                {
                                    String rejection = String.Format("protocol versions do not match (server is {0}, you are {1})",
                                                                     ProtocolInformation.ProtocolVersion, clientProtoVersion);
                                    msg.SenderConnection.Deny(rejection);
                                    break;
                                }

                                TeamType team = (TeamType)msg.ReadByte();
                                String callsign = msg.ReadString();
                                String tag = msg.ReadString();

                                PlayerInformation playerInfo = new PlayerInformation(ProtocolInformation.DummySlot, callsign, tag, team);

                                gameKeeper.AddPlayer(msg.SenderConnection, playerInfo);

                                break;
                            }

                        case NetIncomingMessageType.Data:
                            gameKeeper.HandleIncomingData(msg);
                            break;

                        default:
                            // welp... what shall we do?
                            break;
                    }

                    // reduce GC pressure by recycling
                    server.Recycle(msg);
                }

                // see if we need to run an update pass
                if ((lastUpdate + updateInterval) <= DateTime.Now)
                {
                    lastUpdate = DateTime.Now;
                    gameKeeper.Update(lastUpdate);
                }

                // we must sleep otherwise we will lock everything up
                System.Threading.Thread.Sleep(1);
            }
        }
Esempio n. 57
0
	public SavedContent()
	{
        HeroStats = PlayerManager.Instance.Hero;
		//Scenes = new List<SavedScene>();
	}
Esempio n. 58
0
        public void AddPlayer(NetConnection connection, PlayerInformation playerInfo)
        {
            String denyReason;
            Byte slot = AllocateSlot(playerInfo, out denyReason);

            // could not allocate the player if AllocateSlot returns DummySlot
            if (slot == ProtocolInformation.DummySlot)
            {
                Log.InfoFormat("Player \"{0}\" from {1} tried to join, but was rejected ({2}).",
                               playerInfo.Callsign, connection, denyReason);
                connection.Deny(denyReason);
                return;
            }

            // we can now approve the player if we get here
            connection.Approve();

            // add player to our list
            players[slot] = new Player(this, slot, connection, playerInfo);

            // and tell everyone else about this awesome new player
            Log.DebugFormat("Sending MsgAddPlayer to everyone else about player #{0}", slot);

            NetOutgoingMessage packet = Server.CreateMessage();

            MsgAddPlayerPacket message = new MsgAddPlayerPacket(players[slot].PlayerInfo, false);

            packet.Write((Byte)message.MsgType);
            message.Write(packet);

            Log.DebugFormat("MsgAddPlayer Compiled ({0} bytes) and being sent to {1} recipients",
                            packet.LengthBytes, players.Count - 1);

            // send to everyone except our new player, we let Player itself decide when to send the state to the new guy
            Server.SendToAll(packet, connection, NetDeliveryMethod.ReliableOrdered, 0);
        }
Esempio n. 59
0
    void Awake()
    {
        #if UNITY_EDITOR
        savePath = Application.dataPath + "/Resources/Player Data/" + fileName + ".xml";
        #endif

        #if !UNITY_EDITOR
        savePath = Application.persistentDataPath + "/" + fileName + ".xml";
        #endif

        if (!instance)
        {
            instance = this;
        }

        DontDestroyOnLoad (gameObject);
    }
Esempio n. 60
0
 protected static Texture2D GetTexture(World world, PlayerInformation playerInfo)
 {
     // TODO get the correct texture depending on team
     return world.Content.Load<Texture2D>("textures/tank_white");
 }