Example #1
0
    public void ChangeWeaponAndSetDefaultShooting()
    {
        var contexts = new Contexts();

        var changeWeaponSystem = new ChangeWeaponSystem(contexts);

        var craftingElement = contexts.game.CreateEntity();

        craftingElement.AddUsage(UsageType.Craft);
        craftingElement.isInsideInventory = true;
        craftingElement.AddIngredient(IngredientsType.Crystal);

        PlayerDescription playerDescription = new PlayerDescription()
        {
            ConstantPowerDescription = new ConstantPowerDescription()
            {
                ShowPower = 10
            }
        };

        var player = contexts.game.SetPlayer(playerDescription);

        player.ReplaceWeapon(WeaponType.ConstantPower);

        changeWeaponSystem.Execute();

        Assert.IsTrue(player.hasWeapon);
        Assert.IsTrue(player.hasShotPower);
        Assert.IsTrue(player.hasCurrentProjectile);
        Assert.AreEqual(craftingElement, player.currentProjectile.value);
    }
Example #2
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     foreach (GameObject go in _players)
     {
         if (Input.GetKeyDown("s"))
         {
             Player playerComponent = go.GetComponent <Player>();
             string filePath        = Application.dataPath + levelsFolder + this.exportedFileName + ".json";
             string json            = JsonUtility.ToJson(new PlayerDescription(playerComponent));
             Debug.Log(json);
             File.WriteAllText(filePath, json);
         }
         else if (Input.GetKeyDown("l"))
         {
             string            path = Application.dataPath + levelsFolder + this.exportedFileName + ".json";
             PlayerDescription playerDescription = JsonUtility.FromJson <PlayerDescription>(File.ReadAllText(path));
             Player            playerComponent   = go.GetComponent <Player>();
             foreach (GameObject gameObject in playerComponent.globalDeck)
             {
                 GameObjectManager.unbind(gameObject);
                 GameObject.Destroy(gameObject);
             }
             foreach (GameObject gameObject in playerComponent.levelDeck)
             {
                 GameObjectManager.unbind(gameObject);
                 GameObject.Destroy(gameObject);
             }
             playerComponent.globalDeck.Clear();
             playerComponent.levelDeck.Clear();
             playerComponent.globalDeck = CardDescription.getGameObjects(playerDescription.globalDeck, go);
         }
     }
 }
    // Creates a number of player GameObjects from playerPrefabs
    public GameObject[] CreatePlayers(PlayerDescription[] playerDescriptions)
    {
        AyloDebug.Assert(playerDescriptions.Length <= 8);

        var numberOfPlayers = playerDescriptions.Length;
        players = new List<Player>();
        var positions = new RowPositions(numberOfPlayers);
        var playerColors = PlayerColors.GetColors();

        for(uint i = 0; i < numberOfPlayers; i++) {
            var playerGameObject = (GameObject)Instantiate(playerPrefabs[0]);
            var playerClass = playerDescriptions[i].playerClass;
            var playerColorIndex = playerDescriptions[i].playerColorIndex;
            var playerColor = playerColors[playerDescriptions[i].playerColorIndex];
            var player = new Player(playerGameObject, i, playerClass);

            player.Color = playerColor;
            player.Position = positions.GetNextPosition();
            players.Add(player);
        }

        // this is temporary
        var playerGameObjects = new List<GameObject>();
        foreach(var player in players)
            playerGameObjects.Add(player.GameObject);
        return playerGameObjects.ToArray();
    }
Example #4
0
    public override bool acceptMessageData(BinaryReader messageDataReader, TreeView outputTreeView)
    {
        bool handled = true;

        PacketOpcode opcode = Util.readOpcode(messageDataReader);

        switch (opcode)
        {
        case PacketOpcode.Evt_Login__CharacterSet_ID: {
            Login__CharacterSet message = Login__CharacterSet.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.Evt_Login__WorldInfo_ID: {
            WorldInfo message = WorldInfo.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        case PacketOpcode.PLAYER_DESCRIPTION_EVENT:
        {
            PlayerDescription message = PlayerDescription.read(messageDataReader);
            message.contributeToTreeView(outputTreeView);
            break;
        }

        default: {
            handled = false;
            break;
        }
        }

        return(handled);
    }
Example #5
0
    public void ReplacePlayer(PlayerDescription newPlayerDescription)
    {
        var index     = GameComponentsLookup.Player;
        var component = CreateComponent <PlayerComponent>(index);

        component.PlayerDescription = newPlayerDescription;
        ReplaceComponent(index, component);
    }
Example #6
0
 public override void Show()
 {
     base.Show();
     if (StageData.MenuGroupList[StageData.MenuGroupList.Count - 1] != this)
     {
         return;
     }
     PlayerDescription.ForEach(x => x.Show());
 }
Example #7
0
 public void InitializePlayerDescriptions(D2DSpriteBatch batch)
 {
     if (playerDescriptions != null)
     {
         return;
     }
     playerDescriptions    = new PlayerDescription[charactorCount];
     playerDescriptions[0] = new PlayerDescription(batch, "八頭身モナー", "たま", "なみ", "おこる", "..\\..\\..\\hattousin.gif");
     playerDescriptions[1] = new PlayerDescription(batch, "初音ミク", "ネギビーム", "ネギカッター", "ネギバースト", "..\\..\\..\\miku.png");
 }
Example #8
0
    void Awake()
    {
        //initializing values

        if(!playerFactory)
            getPlayers = GameObject.FindGameObjectsWithTag ("Player"); // So the scenes without a PlayerFactory won't break.
        else if(GameObject.Find("playerDescriptions")) {
            // This is the "real" one. The two other cases are only there to make things work during the transition.
            var playerDescriptions = GameObject.Find("playerDescriptions").GetComponent<PlayerDescriptions>().descriptions;
            getPlayers = playerFactory.CreatePlayers(playerDescriptions);
        }
        else {
            // So scenes with a PlayerFactory but with PlayerDescriptions (from the player selection screen) won't break.
            var playerDescriptions = new PlayerDescription[playerClasses.Length];
            for(int i = 0; i < playerClasses.Length; i++) {
                var description = new PlayerDescription();
                description.playerClass = playerClasses[i];
                description.playerColorIndex = i;
                playerDescriptions[i] = description;
            }

            getPlayers = playerFactory.CreatePlayers(playerDescriptions);
        }

        walkers = GameObject.FindGameObjectsWithTag ("Walker");
        playerTransforms = new Transform[getPlayers.Length]; //Create a reference to the transforms of the players
        playerHP = new int[getPlayers.Length];
        playerMaxHP = new int[getPlayers.Length];
        playerNames = new playerNum[getPlayers.Length];
        getDamage = new damageControl[getPlayers.Length];
        playerCount = getPlayers.Length;
        walkerCount = walkers.Length;
        killCount = new int[getPlayers.Length];
        //playerIndexer = new int[getPlayers.Length];

        if (MultiplayOn == true) {multiplayer = true;} else {multiplayer = false;}
        //hahah rewrite this
        foreach (GameObject walker in walkers) {
            walkerHealth += walker.GetComponent<damageControl>().myHP;
                }
        //Debug.Log ("Number of players = " + playerCount);
        //Debug.Log ("Walker Count = " + walkerCount + " & Together they have: " + walkerHealth + "hp");

        //assign player transforms.
        for (int i = 0; i < getPlayers.Length; i++) {
            //store references to transforms
            playerTransforms[i] = getPlayers[i].GetComponent<Transform>();
            //storeReferences to playerHP
            getDamage[i] = getPlayers[i].GetComponent<damageControl>();
            playerHP[i] = getDamage[i].myHP;
            playerMaxHP[i] = getDamage[i].myMaxHp;
            playerNames[i] = getPlayers[i].GetComponent<playerMovement>().thisPlayer;
            Debug.Log(playerNames[i] + " P" + (i + 1) + " HP: " + playerHP[i] + "/" + playerMaxHP[i]);
        }
    }
Example #9
0
 private void SetPlayerDescription(PlayerDescription desc)
 {
     if (currentPlayerDescription != null)
     {
         currentPlayerDescription.gameObject.SetActive(false);
     }
     currentPlayerDescription = desc;
     desc.gameObject.SetActive(true);
     gravity = desc.gravity;
     speedX  = runSpeed;
 }
Example #10
0
        public void RefreshPlayerDescription()
        {
            var wrapper = new ScriptWrapper(Settings.PlayerDescription);

            wrapper.Execute();
            PlayerDescription.Clear();
            foreach (var res in wrapper.TextResult)
            {
                PlayerDescription.Add(res);
            }
        }
Example #11
0
 private void Start()
 {
     playerType        = PlayerType.empty;
     player            = GameObject.FindWithTag("Player");
     info              = GameObject.FindObjectOfType <PlayerInfo>();
     playerDescription = GameObject.FindObjectOfType <PlayerDescription>();
     CloseDescription();
     widthRatio      = (float)Screen.width / 1024;
     heightRatio     = (float)Screen.height / 768;
     rect            = GetComponent <RectTransform>();
     rect.localScale = new Vector2(widthRatio, heightRatio);
 }
Example #12
0
    public GameEntity SetPlayer(PlayerDescription newPlayerDescription)
    {
        if (hasPlayer)
        {
            throw new Entitas.EntitasException("Could not set Player!\n" + this + " already has an entity with PlayerComponent!",
                                               "You should check if the context already has a playerEntity before setting it or use context.ReplacePlayer().");
        }
        var entity = CreateEntity();

        entity.AddPlayer(newPlayerDescription);
        return(entity);
    }
Example #13
0
        public static PlayerDescription read(BinaryReader binaryReader)
        {
            PlayerDescription newObj = new PlayerDescription();

            newObj.CACQualities = CACQualities.read(binaryReader);
            newObj.PlayerModule = CM_Character.PlayerModule.read(binaryReader);
            newObj.clist        = PList <ContentProfile> .read(binaryReader);

            newObj.ilist = PList <InventoryPlacement> .read(binaryReader);

            return(newObj);
        }
Example #14
0
 private void InitForPlayer(int i, PlayerDescription playerDescription, bool aiControlled)
 {
     _pool.CreateEntity().AddPlayer(i);
     foreach (var gameObject in playerDescription.Buildings)
     {
         var playerInitable = gameObject.GetComponent <IPlayerInitable>();
         if (playerInitable != null)
         {
             playerInitable.Init(_pool, i);
             playerInitable.Entity.isAiControlled = aiControlled;
         }
     }
 }
Example #15
0
    public void ReplacePlayer(PlayerDescription newPlayerDescription)
    {
        var entity = playerEntity;

        if (entity == null)
        {
            entity = SetPlayer(newPlayerDescription);
        }
        else
        {
            entity.ReplacePlayer(newPlayerDescription);
        }
    }
    protected override void Execute(List <GameEntity> entities)
    {
        var player = entities.SingleEntity();
        PlayerDescription playerDesc = player.player.PlayerDescription;

        switch (player.weapon.WeaponType)
        {
        case WeaponType.ConstantPower:
        {
            player.ReplaceShotPower(playerDesc.ConstantPowerDescription.ShowPower);
            var inventoryItem = _inventory.GetEntities().FirstOrDefault(x => x.usage.value == UsageType.Craft);
            if (inventoryItem != null)
            {
                player.ReplaceCurrentProjectile(inventoryItem);
            }
            else
            {
                if (player.hasCurrentProjectile)
                {
                    player.RemoveCurrentProjectile();
                }
            }
        }
        break;

        case WeaponType.Slingshot:
        {
            if (player.hasShotPower)
            {
                player.RemoveShotPower();
            }

            var inventoryItem = _inventory.GetEntities().FirstOrDefault(x => x.usage.value == UsageType.Weapon);
            if (inventoryItem != null)
            {
                player.ReplaceCurrentProjectile(inventoryItem);
            }
            else
            {
                if (player.hasCurrentProjectile)
                {
                    player.RemoveCurrentProjectile();
                }
            }
        }
        break;
        }
    }
Example #17
0
        public MainWindowViewModel(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;
            this.AddCompositeDisposable();
            this.DiceRollCommand.Subscribe(() => this.ExecuteDiceRoll());

            this.playerDescription = new PlayerDescription(this.playerSex, this.playerRace, this.playerPersonality, this.playerClass);
            this.SexesComboBox     = this.playerSex.SexMap;
            this.SelectedPlayerSex.Subscribe(x => this.UpdateSex(x));
            this.RacesComboBox = this.playerRace.RaceMap;
            this.SelectedPlayerRace.Subscribe(x => this.UpdateRace(x));
            this.PersonalitiesComboBox = this.playerPersonality.PersonalityMap;
            this.SelectedPlayerPersonality.Subscribe(x => this.UpdatePersonality(x));
            this.ClassesComboBox = this.playerClass.ClassMap;
            this.SelectedPlayerClass.Subscribe(x => this.UpdateClass(x));
            this.FirstRealmsComboBox.Subscribe(_ => this.UpdateRealmsComboBoxFirst());
            this.SecondRealmsComboBox.Subscribe(_ => this.UpdateRealmssComboBoxSecond());
            this.SelectedPlayerRealmFirst.Subscribe(_ => this.UpdateRealmFirst());
            this.SelectedPlayerRealmSecond.Subscribe(_ => this.UpdateRealmSecond());
        }
Example #18
0
    public void ChangeWeaponType()
    {
        var contexts = new Contexts();

        var changeWeaponSystem = new ChangeWeaponSystem(contexts);

        PlayerDescription playerDescription = new PlayerDescription()
        {
            ConstantPowerDescription = new ConstantPowerDescription()
            {
                ShowPower = 10
            }
        };

        var player = contexts.game.SetPlayer(playerDescription);

        player.ReplaceWeapon(WeaponType.ConstantPower);

        changeWeaponSystem.Execute();

        Assert.IsTrue(player.hasWeapon);
        Assert.IsTrue(player.hasShotPower);
        Assert.IsFalse(player.hasCurrentProjectile);
    }
Example #19
0
 private void Start()
 {
     button            = GetComponent <Button>();
     playerDescription = GameObject.FindObjectOfType <PlayerDescription>();
 }
        void PreparePlayerDescriptions()
        {
            int nPlayers = NumberOfJoinedPlayers();
            var descriptions = new PlayerDescription[nPlayers];

            for(int i = 0; i < nPlayers; i++) {
                var player = players[i];
                var description = new PlayerDescription();

                description.playerColorIndex = player.ColorIndex;
                description.playerClass = (playerClass)player.PlayerClass;

                descriptions[i] = description;
            }

            var playerDescriptionsGameObject = GameObject.Find("playerDescriptions");
            GameObject.DontDestroyOnLoad(playerDescriptionsGameObject);
            var playerDescriptions = playerDescriptionsGameObject.GetComponent<PlayerDescriptions>();
            playerDescriptions.descriptions = descriptions;
        }