Пример #1
0
    // Initialize Player, Spawnpoint, etc.
    void Start () {

        //zeigerLayerMask = LayerMask.NameToLayer ( "Zeiger" );
        //nichtZeigerLayerMask = ~zeigerLayerMask;

        gameController = FindObjectOfType<GameController> ();

        gameObject.name = PLAYER_ID_PREFIX + netId.ToString ();

        //CmdRegisterThisPlayer ();

        motor = GetComponent<PlayerMotor> ();
        cam = GetComponentInChildren<Camera> ();

        Pointer = Instantiate ( PointerPrefab );
        
        //TODO: 
        //  try LoadPlayer
        //  if player = null;
        //Erstellt einen Leeren Spieler
        playerData = new PlayerData ();

        Cursor.lockState = CursorLockMode.Confined;

    }
Пример #2
0
 public PlayerData LoadData()
 {
     PlayerData data;
     if(File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
     {
         BinaryFormatter bf = new BinaryFormatter();
         FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat",FileMode.Open);
         data = (PlayerData)bf.Deserialize(file);
         file.Close();
     }
     else
     {
         BinaryFormatter bf = new BinaryFormatter();
         FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat");
         data = new PlayerData();
         data.highestScore = 0;
         data.totalScore = 0;
         data.cubesDestroyed = 0;
         data.lastScore = 0;
         data.purpleCubes = 0;
         data.blueCubes = 0;
         data.redCubes = 0;
         data.yellowCubes = 0;
         data.greenCubes = 0;
         data.isHighScore = false;
         bf.Serialize(file, data);
         file.Close();
     }
     return data;
 }
Пример #3
0
 void Awake()
 {
     inventoryData = this.gameObject.GetComponent<InventoryData>();
     inventoryLogic = this.gameObject.GetComponent<InventoryLogic>();
     playerData = GameObject.Find("Player").GetComponent<PlayerData>();
     playerLogic = GameObject.Find("Player").GetComponent<PlayerLogic>();
 }
Пример #4
0
 void LoadPlayerData( )
 {
     _Rester.GetJSON( ServerURL + "/players/" + _PlayerId, ( err, result ) =>
     {
         _PlayerData = new PlayerData( result );
     } );
 }
Пример #5
0
    public void Save(int score, int cubesDestroyed, int purpleCubes, int blueCubes, int redCubes, int yellowCubes, int greenCubes)
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat");
        PlayerData data = new PlayerData();

        if (score > data.highestScore)
        {
            data.highestScore = score;
            data.isHighScore = true;
        }
        else
            data.isHighScore = false;

        data.totalScore += score;
        data.cubesDestroyed += cubesDestroyed;
        data.lastScore = score;
        data.purpleCubes = purpleCubes;
        data.blueCubes = blueCubes;
        data.redCubes = redCubes;
        data.yellowCubes = yellowCubes;
        data.greenCubes = greenCubes;


        bf.Serialize(file, data);
        file.Close();
    }
Пример #6
0
 void Awake()
 {
     playerData = GameObject.FindWithTag("Player2D").GetComponent<PlayerData>();
     scoreText2D = GameObject.Find("Score2D").GetComponent<Text>();
     scoreText3D = GameObject.Find("Score3D").GetComponent<Text>();
     ScoreDraw ();
 }
Пример #7
0
    public void load()
    {
        //Create the GameControl and a Player.
        //Checks that loads are correctly done.
        GameControl subGameControl = new GameControl();
        PlayerData subPlayerData = new PlayerData();
        subGameControl.playerData = subPlayerData;

        subPlayerData.playerStr = 8;
        subPlayerData.playerAgl = 7;
        subPlayerData.playerDex = 6;
        subPlayerData.playerInt = 5;
        subPlayerData.playerVit = 4;
        subPlayerData.currentGameLevel = 3;
        subPlayerData.abilityPoints = 2;

        subGameControl.Load();

        Assert.That(subGameControl.playerStr == 8);
        Assert.That(subGameControl.playerAgl == 7);
        Assert.That(subGameControl.playerDex == 6);
        Assert.That(subGameControl.playerInt == 5);
        Assert.That(subGameControl.playerVit == 4);
        Assert.That(subGameControl.currentGameLevel == 3);
        Assert.That(subGameControl.abilityPoints == 2);
    }
Пример #8
0
 public void ReadDBFile()
 {
     PlayerData data = new PlayerData ();
     try
     {
         using( StreamReader sr = new StreamReader(Application.persistentDataPath+"/playerData.data") )
         {
             string line;
             while( (line = sr.ReadLine()) != null)
             {
                 this.tmpData = line.Split('|');
                 data.name = tmpData[0];
                 data.item = int.Parse( tmpData[1] );
                 data.lastPlayDate = DateTime.Parse( tmpData[2] );
             }
         }
         this.playerData = data;
     }
     catch(Exception e)
     {
         Debug.Log ("¡El archivo no puede ser leido!: "+e.Message);
         this.playerData.name = "XYZ";
         this.playerData.item = 0;
         this.playerData.lastPlayDate = DateTime.Now;
     }
 }
Пример #9
0
	// Use this for initialization
	void Awake () {

		pd = PlayerData.Instance;

		//sm = SoundManagerScript.Instance;
		efm = EffectSoundManagerScript.Instance;

		scrollBar = GameObject.Find ("ScrollBar");
		//loadNorm_N_Score ();
//		sm = SoundManagerScript.Instance;
//		sm.playSnd ();

		go_HotMenuBase = GameObject.Find ("HotMenuBase");
		go_HotMenu = GameObject.Find ("HotMenu");

		go_FillRect_HotMenu = GameObject.Find ("FillRect_HotMenu");
		go_FillRect_HotMenu.SetActive (false);

		select_planet = 0;

		go_Planet = new GameObject[PLANET_SIZE];

		createPlanet ();

		setScrollBarValue ();
	}
    PlayerSelector ps; //An instance of the script PlayerSelector (handles how the panels behave)

    #endregion Fields

    #region Methods

    //Function to load the main game scene
    public void LoadLevel(string name)
    {
        PlayerData[] _PlayerData = new PlayerData[num_players]; //Change The player1move to an array
        for(int i = 0; i < num_players; i++)
        {
            switch (i)
            {
                case 0:
                    player1move.CreatePlayerData();
                    _PlayerData[i] = player1move.ThisPlayerData;
                    break;
                case 1:
                    player2move.CreatePlayerData();
                    _PlayerData[i] = player2move.ThisPlayerData;
                    break;
                case 2:
                    player3move.CreatePlayerData();
                    _PlayerData[i] = player3move.ThisPlayerData;
                    break;
                case 3:
                    player4move.CreatePlayerData();
                    _PlayerData[i] = player4move.ThisPlayerData;
                    break;
            }
        }

        Data.selectCars(_PlayerData);
        Invoke("StartGame", 1);
    }
Пример #11
0
 public UiPlayerListItem AddPlayer(PlayerData player)
 {
     var instance = UiUtility.AddChild(List, Prototype, true);
     instance.Tick.SetActive(false);
     instance.Name.text = player.Name;
     return instance;
 }
Пример #12
0
	// Use this for initialization
	void Start () 
	{
		GameObject tempObj = GameObject.Find("PlayerData");
		if (tempObj == null)
		{
			petIndex = 2;
		}
		else
		{
			playerData = tempObj.GetComponent<PlayerData>();
			print("Selected character: " + playerData.selectedPet);
			petIndex = playerData.selectedPet;
		}
		for (int i = 0; i < pets.Length; i++)
		{
			pets[i].SetActive(false);
			if (i == petIndex)
			{
				pets[i].SetActive(true);
				currentPet = pets[i];
			}
		}
		if (camera != null) 
		{
			camera.GetComponent<CameraController>().target = currentPet.transform;
		}
	}
Пример #13
0
 PlayerData GeneratePlayerData(NetworkPlayer player)
 {
     PlayerData newPlayer = new PlayerData();
     newPlayer.player = player;
     newPlayer.team = -1;
     return newPlayer;
 }
Пример #14
0
	public void Save(PlayerData data){
		BinaryFormatter bf = new BinaryFormatter ();
		FileStream file = File.Create (Application.persistentDataPath + "/Save.sav");

		bf.Serialize (file, data);
		file.Close ();
	}
Пример #15
0
	void Start()
	{
		player = GameObject.Find(_DATA).GetComponent<PlayerData>();
		game 	 = GameObject.Find(GAME_MANAGER).GetComponent<GameManager>();

		Init();
	}
Пример #16
0
    /// <summary>
    /// Serializes data for all platforms (except Web Player)
    /// </summary>
    public void Save()
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream file;
        //FileStream file = File.Create(Application.persistentDataPath + "/PlayerInfo.dat");

        if (File.Exists(Application.persistentDataPath + "/PlayerInfo.dat"))
        {
            file = File.Open(Application.persistentDataPath + "/PlayerInfo.dat", FileMode.Open);
        }
        else
        {
            file = File.Create(Application.persistentDataPath + "/PlayerInfo.dat");
            //file = File.Open(Application.persistentDataPath + "/PlayerInfo.dat", FileMode.Open);
        }

        PlayerData data = new PlayerData();
        data.health = health;
        data.experience = experience;

        //writes data container to file
        bf.Serialize(file, data);

        //close file
        file.Close();
    }
Пример #17
0
 /// <summary>
 /// 自分と同じ内容のオブジェクトを作成し、返却する関数
 /// </summary>
 /// <param name="obj"></param>
 public PlayerData Clone()
 {
     PlayerData obj = new PlayerData();
     obj.attack = this.attack;
     obj.characterNumber = this.characterNumber;
     obj.defense = this.defense;
     obj.HP = this.HP;
     obj.intelligence = this.intelligence;
     obj.job = this.job;
     obj.logoutScene = logoutScene;
     obj.Lv = this.Lv;
     obj.nowExp = this.nowExp;
     obj.magicAttack = this.magicAttack;
     obj.magicDefence = this.magicDefence;
     obj.MaxHP = this.MaxHP;
     obj.MaxSP = this.MaxSP;
     obj.mnd = this.mnd;
     obj.name = (string)this.name.Clone();
     obj.skillLevel = new int[20];
     for (int i = 0; i < 20; i++)
     {
         obj.skillLevel[i] = this.skillLevel[i];
     }
     obj.skillPoint = this.skillPoint;
     obj.SP = this.SP;
     obj.statusPoint = this.statusPoint;
     obj.str = this.str;
     obj.vit = this.vit;
     obj.x = this.x;
     obj.y = this.y;
     obj.z = this.z;
     return obj;
 }
Пример #18
0
 void Start()
 {
     //Get the data
     var data = PlayerPrefs.GetString("PData");
     //If not blank then load it
     if(!string.IsNullOrEmpty(data))
     {
         //Binary formatter for loading back
         var b = new BinaryFormatter();
         //Create a memory stream with the data
         var m = new MemoryStream(Convert.FromBase64String(data));
         //Load back the scores
         playerDataList = (List<PlayerData>)b.Deserialize(m);
         PData = playerDataList.First();
         print (PData.name);
         if(PData.name == "SAVED NAME"){
             PData.name = "Second Name";
         } else {
             PData.name = "SAVED NAME";
         }
         SaveData ();
     } else
     {
         PData.name = "FAKE NAME";
         print (PData.name);
         PData.name= "SAVED NAME";
         SaveData();
     }
 }
Пример #19
0
 void Awake()
 {
     enemyLogic = this.gameObject.GetComponent<EnemyLogic>();
     enemyData = this.gameObject.GetComponent<EnemyData>();
     playerData = GameObject.Find("Player").GetComponent<PlayerData>();
     gameStateData = GameObject.Find("GameState").GetComponent<GameStateData>();
 }
Пример #20
0
 public void SendName(string name, NetworkMessageInfo info)
 {
     PlayerData player = new PlayerData();
     player.name = name;
     player.player = info.sender;
     int playerIndex = -1;
     for (int i = 0; i < MAX_PLAYERS; i++)
     {
         if (players[i] == null)
         {
             playerIndex = i;
             break;
         }
     }
     if (playerIndex >= 0)
     {
         players[playerIndex] = player;
         GameObject chatObject = GameObject.FindGameObjectWithTag("Chat");
         if (chatObject != null)
         {
             Chat2 chat = chatObject.GetComponent<Chat2>();
             if (chat != null)
             {
                 chat.SendMessage("Joined: " + player.name);
             }
         }
         Debug.Log("PLAYER LOGGED IN AS " + player.name);
     }
     else
     {
         Debug.Log("CANNOT LOG IN PLAYER -- ALL SLOTS TAKEN");
     }
 }
Пример #21
0
	public void startLevel() {
		Application.LoadLevel(1);
        PlayerData data = new PlayerData(){
            currentLevel = 1
        };
        DataSave.SaveData(data);
	}
Пример #22
0
        /// <summary>
        /// Constructor used to initialize a new BoggleServer. This will initialize the GameLength
        /// and it will build a dictionary of all of the valid words from the DictionaryPath. If an
        /// optional string was passed to this application, then it will build a BoggleBoard from
        /// the supplied string. Otherwise it will build a BoggleBoard randomly.
        /// </summary>
        /// <param name="GameLength">The length that the Boggle game should take.</param>
        /// <param name="DictionaryPath">The filepath to the dictionary that should be used to
        /// compare words against.</param>
        /// <param name="OptionalString">An optional string to construct a BoggleBoard with.</param>
        public BoggleServer(int GameLength, string DictionaryPath, string OptionalString)
        {
            try
            {
                this.UnderlyingServer = new TcpListener(IPAddress.Any, 2000);
                this.GameLength = GameLength;
                this.DictionaryWords = new HashSet<string>(File.ReadAllLines(DictionaryPath));
                this.WaitingPlayer = null;

                this.CommandReceived = new Object();
                this.ConnectionReceivedLock = new Object();

                if (OptionalString != null)
                    this.OptionalString = OptionalString;

                Console.WriteLine("The Server has Started on Port 2000");

                // Start the server and begin accepting clients.
                UnderlyingServer.Start();
                UnderlyingServer.BeginAcceptSocket(ConnectionReceived, null);

            }

            // If any exception occured when starting the sever or connecting clients,
            // print out an error message and the stacktrace where the error occured.
            catch (Exception e)
            {
                Console.WriteLine("An Exception Occured When Building the BoggleServer:");
                Console.WriteLine(e.ToString());
            }
        }
Пример #23
0
    public void Setup()
    {
        SETUP = MainTitleUI.getSetup();
        PLAYERDATA = GameObject.FindGameObjectWithTag("PlayerData").GetComponent<PlayerData>();
        PLAYERDATA.Launch();
        ThumbGO = new GameObject("Thumbnails");
        ThumbGO.transform.parent = gameObject.transform;
        ThumbGO.transform.localPosition = new Vector3(0f,0f,0f);
        levelName = FETool.findWithinChildren(gameObject, "LevelTitle/LEVEL_NAME").GetComponent<TextUI>();
        _btnLeft = FETool.findWithinChildren(gameObject, "SelectLeft").GetComponent<LevelChooserButton>();
        _btnRight = FETool.findWithinChildren(gameObject, "SelectRight").GetComponent<LevelChooserButton>();

        Thumbs.Clear();
        foreach (LevelInfo _lvl in PLAYERDATA.PROFILE.ActivatedLevels)
        {
            LevelThumbnail _th = CreateThumbnail(_lvl);
            Thumbs.Add(_th);
        }
        for (int j = 0; j < Thumbs.Count ; j++)
        {
        //			Thumbs[j].gameObject.transform.localPosition = new Vector3(0f,0f,0f);
            Thumbs[j].gameObject.transform.localPosition = new Vector3(j * gapThumbs.x, 0f, gapThumbs.z);
        }

        Thumbs[0].isStartSlot = true;
        Thumbs[Thumbs.Count-1].isEndSlot = true;

        _btnLeft.Setup(this, LevelChooserButton.DirectionList.Left);
        _btnRight.Setup(this, LevelChooserButton.DirectionList.Right);
        currThumb = Thumbs[0];
        levelName.text = currThumb.nameLv.ToString();
        checkCurrThumb();
    }
Пример #24
0
    public void setSprites(PlayerData.Country myCountry)
    {
        int index = 0;

        switch (myCountry) {

        case PlayerData.Country.China:
            index = 0;
            break;
        case PlayerData.Country.Japan:
            index = 1;
            break;
        case PlayerData.Country.Russia:
            index = 2;
            break;
        case PlayerData.Country.USA:
            index = 3;
            break;
        }

        myTorso.sprite = torso[index];
        myFrontArm.sprite = frontArm[index];
        myBackArm.sprite = backArm[index];
        myFrontLeg.sprite = frontLeg[index];
        myBackLeg.sprite = backLeg[index];
    }
    protected void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player" && other.name == "Player")
        {
            Player player = other.gameObject.GetComponent<Player>();
            PlayerData data = new PlayerData();

            if (changeScene)
            {
                // if checkpoint changes scene, save values for the new scene
                data.playerPosition = DataManager.Vector3ToString(new Vector3(0, 0, 0));
                // data.levelID = player.CurrentLevel + 1;
            }
            else
            {
                data.playerPosition = DataManager.Vector3ToString(other.gameObject.transform.position);
                // data.levelID = player.CurrentLevel;
            }

            data.playerRotation = DataManager.Vector3ToString(other.gameObject.transform.localEulerAngles);
            data.playerScale = DataManager.Vector3ToString(other.gameObject.transform.localScale);
            data.playerEnergy = other.gameObject.GetComponent<Player>().LightEnergy.CurrentEnergy;
            DataManager.SaveFile(data);

            if (changeScene)
            {
                StartCoroutine(ChangeLevel());
            }
        }
    }
Пример #26
0
	public static void Save(PlayerData data) {
		Stream stream = File.Open (currentFilePath, FileMode.Create);
		BinaryFormatter formatter = new BinaryFormatter ();
		formatter.Binder = new VersionDeserializationBinder ();
		formatter.Serialize (stream, data);
		stream.Close ();
	}
Пример #27
0
 void ReadDBFile(string file)
 {
     try
     {
         using(StreamReader sr = new StreamReader(Application.persistentDataPath + "/" + file))
         {
             //Leo linea a linea el contenido del archivo
             string line;
             //Mientras la linea tenga informacion, parceo su contenido
             while((line = sr.ReadLine()) != null)
             {
                 tmpData = line.Split('|');
                 playerData = new PlayerData(int.Parse(tmpData[0]), tmpData[1], DateTime.Parse(tmpData[2]));
             }
         }
     }
     catch(Exception e)
     {
         Debug.LogWarning("El archivo " + file + " no puede ser leido : " + e.Message);
         playerData = new PlayerData();
         playerData.items = 0;
         playerData.name = "";
         playerData.ultimaPartida = DateTime.Now;
         SavePlayerData();
     }
 }
Пример #28
0
 void Start()
 {
     playerData = GameObject.FindGameObjectWithTag("PlayerData").GetComponent<PlayerData>();
     UpdateDamage();
     // Start Destroy timer
     Destroy(gameObject, destroyTime);
 }
Пример #29
0
 void Awake()
 {
     playerData = GameObject.FindGameObjectWithTag("PlayerData").GetComponent<PlayerData>();
     ApplyUpgrades();
     ammo = _maxAmmo;
     UpdateUI();
 }
Пример #30
0
 /*
 public Text textFR;
 public Text textDmg;
 public Text textAmmo;
 */
 void Awake()
 {
     if (Time.timeScale == 0) {
         Time.timeScale = 1;
     }
     playerData = GameObject.FindGameObjectWithTag("PlayerData").GetComponent<PlayerData>();
 }
Пример #31
0
    // Detect if the shell collides with another collider
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.CompareTag("Enemy"))                              // Check if the collider hit has the "Enemy" tag
        {
            EnemyData enemyData = col.gameObject.GetComponent <EnemyData>(); // Get EnemyData component
            if (enemyData.isInvulnerable == false)                           // If the enemy is NOT invulnerable...
            {
                // Deal damage to enemy tank
                enemyData.tankHealth -= tankData.shellDamage; // Deal damage
                if (enemyData.tankHealth > 0)
                {
                    GameManager.instance.soundManager.SoundTankHit(); // Play sound when tank is hit
                    tankData.score += enemyData.pointValue;
                    // Add explosionHit FX
                    GameObject explosionHitClone = Instantiate(explosionHit, tf.position, tf.rotation);
                    Destroy(explosionHitClone, explosionHitDuration);
                }
                else if (enemyData.tankHealth <= 0)
                {
                    tankData.score += (int)(enemyData.pointValue * GameManager.instance.killMultiplier); // Add score multiplier for destroying tank
                    // Check tank destroyed after collision, rather than checking in Update() to lower resource requirement
                    col.gameObject.GetComponent <EnemyPawn>().TankDestroyed();
                    // Add explosionDestroy FX
                    GameObject explosionDestroyClone = Instantiate(explosionDestroy, tf.position, tf.rotation);
                    Destroy(explosionDestroyClone, explosionDestroyDuration);
                }
            }
            else
            {
                Debug.Log("Enemy is invulnerable");                             // TODO: When message system is up, add enemy invulnerable notification
            }
            Destroy(this.gameObject);                                           // Destroy the cannon shell if it hits an enemy tank
        }
        else if (col.gameObject.CompareTag("Player"))                           // Check if the collider hit has the "Player" tag
        {
            PlayerData playerData = col.gameObject.GetComponent <PlayerData>(); // Get PlayerData component
            if (playerData.isInvulnerable == false)                             // If the player is NOT invulnerable
            {
                // Deal damage to player tank
                playerData.tankHealth -= tankData.shellDamage;

                if (playerData.tankHealth > 0)
                {
                    GameManager.instance.soundManager.SoundTankHit(); // Play sound when tank is hit
                    tankData.score += playerData.pointValue;
                    // Add explosionHit FX
                    GameObject explosionHitClone = Instantiate(explosionHit, tf.position, tf.rotation);
                    Destroy(explosionHitClone, explosionHitDuration);
                }
                else if (playerData.tankHealth <= 0)
                {
                    tankData.score += (int)(playerData.pointValue * GameManager.instance.killMultiplier); // Add score multiplier for destroying tank
                    // Check tank destroyed after collision, rather than checking in Update() to lower resource requirement
                    col.gameObject.GetComponent <PlayerPawn>().TankDestroyed();
                    // Add explosionDestroy FX
                    GameObject explosionDestroyClone = Instantiate(explosionDestroy, tf.position, tf.rotation);
                    Destroy(explosionDestroyClone, explosionDestroyDuration);
                }
            }
            else
            {
                Debug.Log("Player is invulnerable"); // TODO: When message system is up, add player invulnerable notification
            }

            Destroy(this.gameObject); // Destroy the cannon shell if it hits an enemy tank
        }
        else if (col.gameObject.CompareTag("Arena"))
        {
            GameObject explosionHitClone = Instantiate(explosionHit, tf.position, tf.rotation);
            Destroy(explosionHitClone, explosionHitDuration);
            Destroy(this.gameObject); // Destroy the cannon shell if it hits any other collider
        }
    }
Пример #32
0
 public void SetPlayerData(PlayerData playerData)
 {
     _playerData = playerData;
     _dataProxy.SetPlayerData(playerData);
 }
Пример #33
0
        public void Configure(IApplicationBuilder app)
        {
            var serverAddressesFeature = app.ServerFeatures.Get <IServerAddressesFeature>();

            Log.Print(LogType.Server, "Started DirectoryServer on '0.0.0.0:6050'");

            app.Run((context) =>
            {
                context.Response.ContentType = "application/json";
                MemoryStream ms = new MemoryStream();
                context.Request.Body.CopyTo(ms);
                ms.Position        = 0;
                string requestBody = new StreamReader(ms).ReadToEnd();;
                ms.Dispose();

                AssignGameClientRequest request   = JsonConvert.DeserializeObject <AssignGameClientRequest>(requestBody);
                AssignGameClientResponse response = new AssignGameClientResponse();
                response.RequestId    = request.RequestId;
                response.ResponseId   = request.ResponseId;
                response.Success      = true;
                response.ErrorMessage = "";

                PlayerData.Player p;
                try
                {
                    p = PlayerData.GetPlayer(request.AuthInfo.Handle);
                    if (p == null)
                    {
                        Log.Print(LogType.Warning, $"Player {request.AuthInfo.Handle} doesnt exists");
                        PlayerData.CreatePlayer(request.AuthInfo.Handle);
                        p = PlayerData.GetPlayer(request.AuthInfo.Handle);
                        if (p != null)
                        {
                            Log.Print(LogType.Debug, $"Succesfully Registered {p.UserName}");
                        }
                        else
                        {
                            Log.Print(LogType.Error, $"Error creating a new account for player '{request.AuthInfo.UserName}'");
                        }
                    }
                }
                catch (Exception)
                {
                    p           = new PlayerData.Player();
                    p.AccountId = 508;
                    p.UserName  = request.AuthInfo.Handle;
                }

                request.SessionInfo.SessionToken = 0;

                response.SessionInfo                   = request.SessionInfo;
                response.SessionInfo.AccountId         = p.AccountId;
                response.SessionInfo.Handle            = p.UserName;
                response.SessionInfo.ConnectionAddress = "127.0.0.1";
                response.SessionInfo.ProcessCode       = "";
                response.SessionInfo.FakeEntitlements  = "";
                response.SessionInfo.LanguageCode      = "EN"; // Needs to be uppercase

                response.LobbyServerAddress = "127.0.0.1";

                LobbyGameClientProxyInfo proxyInfo = new LobbyGameClientProxyInfo();
                proxyInfo.AccountId      = response.SessionInfo.AccountId;
                proxyInfo.SessionToken   = request.SessionInfo.SessionToken;
                proxyInfo.AssignmentTime = 1565574095;
                proxyInfo.Handle         = request.SessionInfo.Handle;
                proxyInfo.Status         = ClientProxyStatus.Assigned;

                response.ProxyInfo = proxyInfo;

                return(context.Response.WriteAsync(JsonConvert.SerializeObject(response)));
            });
        }
Пример #34
0
 public void SetOwner(PlayerData temp)
 {
     owner = temp;
 }
Пример #35
0
 public PlayerMoveStart(PlayerData gamePlayer)
 {
     player = gamePlayer;
 }
Пример #36
0
 public override void Init()
 {
     base.Init();
     _PlayerData = Context.PlayerData;
 }
Пример #37
0
 public async Task HitPlayerAsync(PlayerData player, Vector3 direction)
 {
     Console.WriteLine(player.Name + " has been hit!");
     Broadcast(room).OnPlayerHit(player, direction);
 }
Пример #38
0
    // this loads the save game slots from disk
    void LoadPlayerDataList()
    {
        // whether or not we have found the current game
        var currentGameFound = false;

        // create the player data list
        m_playerDataList = new PlayerData[c_numSaveGameSlots];

        // go through each save game slot
        for (var i = 0; i < c_numSaveGameSlots; i++)
        {
            // get the path to the player data file
            var filePath = Application.persistentDataPath + "/" + m_playerDataFileName + i + ".bin";

            // keep track of whether or not we were able to load the player data file
            var loadSucceeded = false;

            // check if the file exists
            if (File.Exists(filePath))
            {
                try
                {
                    // try to load the save game file now
                    var file = File.Open(filePath, FileMode.Open);

                    // create the binary formatter
                    var binaryFormatter = new BinaryFormatter();

                    // add support for serializing / deserializing Unity.Vector3
                    var surrogateSelector             = new SurrogateSelector();
                    var vector3SerializationSurrogate = new Vector3SerializationSurrogate();
                    surrogateSelector.AddSurrogate(typeof(Vector3), new StreamingContext(StreamingContextStates.All), vector3SerializationSurrogate);
                    binaryFormatter.SurrogateSelector = surrogateSelector;

                    // load and deserialize the player data file
                    m_playerDataList[i] = (PlayerData)binaryFormatter.Deserialize(file);

                    // we were able to load the save game slots from file (version checking is next)
                    loadSucceeded = true;
                }
                catch
                {
                }
            }

            // if the player data is from an old version then we have to start over
            if (!loadSucceeded || !m_playerDataList[i].IsCurrentVersion())
            {
                // debug info
                UnityEngine.Debug.Log("Creating and resetting player data " + i);

                m_playerDataList[i] = new PlayerData();

                m_playerDataList[i].Reset();
            }

            // check if this is the active save game slot
            if (m_playerDataList[i].m_isCurrentGame)
            {
                // yes - remember the slot number
                m_activeSaveGameSlotNumber = i;

                // point the current player data to this slot
                m_playerData = m_playerDataList[m_activeSaveGameSlotNumber];

                // we have found the current game
                currentGameFound = true;
            }
        }

        // did we not find the current game?
        if (!currentGameFound)
        {
            // nope - use the first slot
            m_activeSaveGameSlotNumber = 0;

            // point the current player data to this slot
            m_playerData = m_playerDataList[m_activeSaveGameSlotNumber];
        }

        // set the target save game slot number to be the same as the active one
        m_targetSaveGameSlotNumber = m_activeSaveGameSlotNumber;
    }
Пример #39
0
 private void Start()
 {
     data = GetComponent <PlayerData>();
 }
Пример #40
0
 public void Save()
 {
     var data = new PlayerData(this);
     SaveHelper.Save(data, "player.sav");
 }
Пример #41
0
 public PlayerRollState(Player player, PlayerStateMachine stateMachine, PlayerData playerData, string animBoolName) : base(player, stateMachine, playerData, animBoolName)
 {
     amountOfRollsLeft = playerData.amountOfRolls;
 }
Пример #42
0
 public PlayerAirState(StateActor actor, StateMachine stateMachine, PlayerData data, string animBoolName) : base(actor, stateMachine, data, animBoolName)
 {
 }
Пример #43
0
 public void Construct(SignalBus signalBus,
                       PlayerData playerData)
 {
     _signalBus = signalBus;
     _coins     = playerData.Coins.Variable;
 }
Пример #44
0
    public void Join(int id)
    {
        PlayerData playerData = GameController.Instance.characterMaster.characterData.FirstOrDefault(x => x.CharacterID == id);

        Join(playerData);
    }
Пример #45
0
        private void OnUpdate(Client client, Packet p)
        {
            UpdatePacket packet = p as UpdatePacket;

            // Get new info.
            foreach (Entity obj in packet.NewObjs)
            {
                // Player info.
                if (Enum.IsDefined(typeof(Classes), (short)obj.ObjectType))
                {
                    PlayerData playerData = new PlayerData(obj.Status.ObjectId);
                    playerData.Class = (Classes)obj.ObjectType;
                    playerData.Pos   = obj.Status.Position;
                    foreach (var data in obj.Status.Data)
                    {
                        playerData.Parse(data.Id, data.IntValue, data.StringValue);
                    }

                    if (playerPositions.ContainsKey(obj.Status.ObjectId))
                    {
                        playerPositions.Remove(obj.Status.ObjectId);
                    }
                    playerPositions.Add(obj.Status.ObjectId, new Target(obj.Status.ObjectId, playerData.Name, playerData.Pos));
                }
                // Portals.
                if (obj.ObjectType == 1810)
                {
                    foreach (var data in obj.Status.Data)
                    {
                        if (data.StringValue != null)
                        {
                            // Get the portal info.
                            // This regex matches the name and the player count of the portal.
                            string pattern = @"\.(\w+) \((\d+)";
                            var    match   = Regex.Match(data.StringValue, pattern);

                            var portal = new Portal(obj.Status.ObjectId, int.Parse(match.Groups[2].Value), match.Groups[1].Value, obj.Status.Position);
                            if (portals.Exists(ptl => ptl.ObjectId == obj.Status.ObjectId))
                            {
                                portals.RemoveAll(ptl => ptl.ObjectId == obj.Status.ObjectId);
                            }
                            portals.Add(portal);
                        }
                    }
                }
                // Enemies. Only look for enemies if EnableEnemyAvoidance is true.
                if (Enum.IsDefined(typeof(EnemyId), (int)obj.ObjectType) && config.EnableEnemyAvoidance)
                {
                    if (enemies.Exists(en => en.ObjectId == obj.Status.ObjectId))
                    {
                        enemies.RemoveAll(en => en.ObjectId == obj.Status.ObjectId);
                    }
                    enemies.Add(new Enemy(obj.Status.ObjectId, obj.Status.Position));
                }

                // Obstacles.
                if (obstacleIds.Contains(obj.ObjectType))
                {
                    if (!obstacles.Exists(obstacle => obstacle.ObjectId == obj.Status.ObjectId))
                    {
                        obstacles.Add(new Obstacle(obj.Status.ObjectId, obj.Status.Position));
                    }
                }
            }

            // Remove old info
            foreach (int dropId in packet.Drops)
            {
                // Remove from players list.
                if (playerPositions.ContainsKey(dropId))
                {
                    if (followTarget && targets.Exists(t => t.ObjectId == dropId))
                    {
                        // If one of the players who left was also a target, remove them from the targets list.
                        targets.Remove(targets.Find(t => t.ObjectId == dropId));
                        Log(string.Format("Dropping \"{0}\" from targets.", playerPositions[dropId].Name));
                        if (targets.Count == 0)
                        {
                            Log("No targets left in target list.");
                            if (config.EscapeIfNoTargets)
                            {
                                Escape(client);
                            }
                        }
                    }
                    playerPositions.Remove(dropId);
                }

                // Remove from enemies list.
                if (enemies.Exists(en => en.ObjectId == dropId))
                {
                    enemies.RemoveAll(en => en.ObjectId == dropId);
                }

                if (portals.Exists(ptl => ptl.ObjectId == dropId))
                {
                    portals.RemoveAll(ptl => ptl.ObjectId == dropId);
                }
            }
        }
Пример #46
0
 public void setPlayerPro(PlayerPro playerPro)
 {
     PlayerPro = new PlayerData(playerPro);
 }
Пример #47
0
    private void Save()
    {
        PlayerData pd = new PlayerData(Health, Experience);

        _Storage.Save(pd);
    }
Пример #48
0
 public void SaveGame()
 {
     Debug.Log("Saving Game...");
     PlayerData.SavePlayerData(SceneManager.GetActiveScene().buildIndex, GameSession.getPlayerLives(), GameSession.getPlayerScore());
 }
Пример #49
0
 public static bool ShowSkillZ(this PlayerData playerData)
 {
     return(ShowSkill(playerData, playerData.SkillZEntityId, DemoValue.SkillZDistance));
 }
Пример #50
0
 // Update is called once per frame
 void Update()
 {
     _currentPlayer = _allPlayer[_currentPlayerIndex];
 }
Пример #51
0
 // Use this for initialization
 void Start()
 {
     instance = this;
     PlayerData.spawnPoint = GetComponent <Transform> ().position;
     deathScreen.SetActive(false);          // Disable the death screen since the player isn't dead yet
 }
Пример #52
0
 public override void Use(PlayerData player)
 {
     throw new System.NotImplementedException();
 }
Пример #53
0
        /// <summary>
        /// This will be called when a player connects.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="playername"></param>
        /// <param name="kickCallback"></param>
        private void PlayerConnected([FromSource] Player player, string playername, CallbackDelegate kickCallback)
        {
            // Make sure that the Client has Steam enabled.
            if (player.Identifiers["steam"] == null)
            {
                player.Drop("STEAM CLIENT not detected, please start or restart your Steam Client to come back.");
                API.CancelEvent();
                return;
            }

            // Make sure the client isn't banned.
            AdminDB.isBanned(player, new Action <PlayerData, bool>((p, isBanned) => {
                if (isBanned)
                {
                    AdminDB.getBannedMessage(player, true, true, new Action <PlayerData, string>((ply, message) =>
                    {
                        ply.getHandler().Drop(message);
                        API.CancelEvent();
                    }));

                    return;
                }
            }));

            if (whitelist_enabled)
            {
                AdminDB.isWhitelisted(player, new Action <PlayerData, bool>((ply, isWhitelisted) =>
                {
                    if (!isWhitelisted)
                    {
                        API.CancelEvent();
                        return;
                    }
                }));
            }

            void clearStopWatch()
            {
                // Clear Memory, if necessary.
                if (lastJoinedStopWatch != null)
                {
                    lastJoinedStopWatch.Reset();
                }

                lastJoinedStopWatch = new Stopwatch();
                lastJoinedStopWatch.Start();
            }

            // Kicks player for spam reconnecting.
            if (lastJoinedPlayer != null)
            {
                if (lastJoinedPlayer.getIdentifier() == player.Identifiers["steam"])
                {
                    long seconds = lastJoinedStopWatch.ElapsedMilliseconds * 1000;
                    if (lastJoinReconnectCounter >= 5 && seconds < 5)
                    {
                        lastJoinedPlayer.BanAsync(null, "Reconnecting to quickly. Come back later.", "1h");
                        lastJoinReconnectCounter = 0;

                        clearStopWatch();
                        API.CancelEvent();
                        return;
                    }
                    else
                    {
                        lastJoinReconnectCounter++;
                    }
                }
                else
                {
                    lastJoinReconnectCounter = 0;
                }
            }

            if (lastJoinedPlayer.getIPAddress() != player.EndPoint || lastJoinedPlayer.getUserName() != player.Name || lastJoinedPlayer.getIdentifier() != player.Identifiers["steam"])
            {
                lastJoinedPlayer = new PlayerData(player);
                clearStopWatch();
            }

            // Search the player.
            PlayerData joiningPlayer = null;

            foreach (PlayerData ply in players)
            {
                if (ply.getIdentifier() == player.Identifiers["steam"])
                {
                    joiningPlayer = ply;
                    break;
                }
            }

            if (joiningPlayer == null)
            {
                PlayerData ply = new PlayerData(player);
                players.Add(ply);
                TriggerEvent("ax:PlayerConnected", ply);
            }
        }
Пример #54
0
 public void Init()
 {
     playerdata = new PlayerData();
 }
Пример #55
0
 private void ChatInvalidCommand(PlayerData arg1, string[] arg2)
 {
 }
Пример #56
0
 public static void ChatMessage(PlayerData player, string message, string title = "")
 {
     player.SendMessage(message, title);
 }
Пример #57
0
 public void SetPlayerData(ResponLogin data)
 {
     playerData = data.playerData;
 }
Пример #58
0
 private void XA_PlayerConnected(PlayerData obj)
 {
     Console.WriteLine("Player Connected -> " + obj.getUserName() + "[" + obj.getHandler().EndPoint.ToString() + " | " + obj.getIdentifier() + "]");
 }
Пример #59
0
 public void ActualizeController()
 {
     controllerData = Controller.GetComponent <PlayerData>();
     // TO DO : Change Etiquette visibility.
 }
Пример #60
0
 private void AddUserToGroup(PlayerData player, Group group)
 {
     player.setUserGroup(group);
     Console.WriteLine("\n " + player.getUserName() + " was set to " + group.getName() + " \n");
 }