示例#1
0
    public IEnumerator LoadPlayerDataFile()
    {
        Debug.Log("LoadPlayerData start");

        string playerDataText = null;

        // loading from persistent data
        string filePath = Application.persistentDataPath + "/PlayerBlob.json";

        if (File.Exists(filePath))
        {
            _fileWWW = new WWW("file://" + filePath);
            yield return(_fileWWW);

            if (_fileWWW.bytes.Length > 0)
            {
                playerDataText = _fileWWW.text;
            }

            _playerBlob = (PlayerBlob)Serializer.Deserialize(typeof(PlayerBlob), playerDataText);
        }
        // first time load
        else
        {
            _playerBlob = PlayerBlob.NewPlayerBlob();
        }

        Debug.Log("LoadPlayerData done!");
    }
示例#2
0
文件: Player.cs 项目: tarnas14/AgarIo
 internal void RemoveBlob(PlayerBlob blob)
 {
     lock (BlobsLock)
     {
         _blobs.Remove(blob);
     }
 }
示例#3
0
文件: Player.cs 项目: tarnas14/AgarIo
 internal void AddBlob(PlayerBlob blob)
 {
     lock (BlobsLock)
     {
         _blobs.Add(blob);
     }
 }
示例#4
0
        private void ApplyPlayerDecisions()
        {
            lock (BlobsListLock)
            {
                foreach (var player in _playerRepository.Players)
                {
                    if (player.Join)
                    {
                        var position   = RemoveFoodAndGetSpawnPosition();
                        var playerBlob = new PlayerBlob(player, this, _physics, _stateTracker, position, true);

                        AddBlob(playerBlob);

                        player.Join = false;

                        continue;
                    }

                    if (!player.Blobs.Any())
                    {
                        continue;
                    }

                    var center = DetermineGoosCenter(player.Blobs);

                    var direction = player.PlayerDecisions.Velocity;
                    foreach (var blob in player.Blobs.Where(x => x.ControlledByPlayer))
                    {
                        var normalizedVelocity = (center + direction - blob.Position).Normalize();
                        var speed = Math.Min(direction.Length, PlayerBlob.GetMaxSpeed(blob.Mass));
                        blob.Velocity = normalizedVelocity * speed;

                        switch (player.PlayerDecisions.Activity)
                        {
                        case Activity.None:
                            break;

                        case Activity.Split:
                            blob.Split();
                            break;

                        case Activity.EjectMass:
                            blob.EjectMass();
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }

                    player.PlayerDecisions.Activity = Activity.None;
                }
            }
        }
示例#5
0
    void Start()
    {
        //  :)
        playerScript = GameObject.Find("Player").GetComponent <PlayerBlob>();
        dialogues    = GameObject.FindGameObjectsWithTag("Dialogue");

        if (Instance)
        {
            Destroy(Instance);
        }
        Instance = this;
    }
示例#6
0
    public static PlayerBlob NewPlayerBlob()
    {
        PlayerBlob blob = new PlayerBlob()
        {
            CharacterBlobSlots = new Dictionary <string, CharacterBlob>()
        };

        for (int i = 0; i < TuningData.Instance.NumSaveSlots; i++)
        {
            blob.CharacterBlobSlots.Add(SLOT_PREFIX + i, null);
        }

        return(blob);
    }
示例#7
0
        public void Init()
        {
            Input.ClearBindings();
            var player  = new PlayerBlob(Color.Red);
            var enemies = new List <EnemyBlob> {
                new EnemyBlob(), new EnemyBlob(), new EnemyBlob(), new EnemyBlob()
            };
            var gameBackground = new GameBackground();

            _visuals.Add(player);
            _visuals.AddRange(enemies);
            _visuals.Add(gameBackground);
            _automatons.Add(player);
            _automatons.AddRange(enemies);
            _automatons.Add(gameBackground);
        }
示例#8
0
        public void Init()
        {
            World.PlayMusic("Music/thechase");
            Input.ClearBindings();
            Input.OnDirection(UpdateCamera);
            _camera = new Camera(new Vector2(775, 425));
            var player  = new PlayerBlob(Color.Red);
            var enemies = new List <EnemyBlob> {
                new EnemyBlob(), new EnemyBlob(), new EnemyBlob(), new EnemyBlob()
            };
            var gameBackground = new GameBackground();

            _visuals.Add(gameBackground);
            _visuals.Add(player);
            _visuals.AddRange(enemies);
            _automatons.Add(gameBackground);
            _automatons.Add(player);
            _automatons.AddRange(enemies);
        }