Esempio n. 1
0
 private static void AddDeployableToList <T>(string uid, int amount, List <IAssetVO> assets, List <string> equipment, StaticDataController dc, SkinController skinController) where T : IValueObject
 {
     if (amount > 0)
     {
         IAssetVO assetVO = dc.GetOptional <T>(uid) as IAssetVO;
         if (assetVO != null)
         {
             if (assetVO is TroopTypeVO)
             {
                 TroopTypeVO troopTypeVO = (TroopTypeVO)assetVO;
                 MapDataLoaderUtils.AddSpawnEffect(troopTypeVO, assets, dc);
                 MapDataLoaderUtils.AddPlanetAttachments(troopTypeVO, assets, dc);
                 SkinTypeVO applicableSkin = skinController.GetApplicableSkin(troopTypeVO, equipment);
                 if (applicableSkin != null)
                 {
                     assetVO = applicableSkin;
                 }
             }
             for (int i = 0; i < amount; i++)
             {
                 assets.Add(assetVO);
             }
         }
     }
 }
Esempio n. 2
0
        public override void Execute()
        {
            if (injectionBinder.GetBinding <PlayerView> (GameElement.PLAYER) != null)
            {
                injectionBinder.Unbind <PlayerView> (GameElement.PLAYER);
            }

            IAssetVO playerAssetVO = gameModel.playerModel.assetVO;

            //add the player's ship
            GameObject playerStyle = resourceManager.getResourceByAssetData(playerAssetVO.assetData);            // Resources.Load<GameObject> (playerAssetVO.assetData.path);
            GameObject playerGO    = GameObject.Instantiate(playerStyle) as GameObject;

            playerGO.name = playerAssetVO.assetData.id;
            playerGO.tag  = PlayerView.ID;
            playerGO.transform.localPosition = new Vector3(position, gameModel.roomModel.bgAssetInfo.startPosY, -0.05f);
            //playerGO.layer = LayerMask.NameToLayer("player");
            playerGO.transform.SetParent(gameField.transform, false);
            playerGO.AddComponent <PlayerView> ();
            PlayerView playerView = playerGO.GetComponent <PlayerView> ();

            playerView.moveForce = gameModel.playerModel.moveForce;
            playerView.maxSpeed  = gameModel.playerModel.moveSpeed;

            injectionBinder.Bind <PlayerView> ().ToValue(playerView).ToName(GameElement.PLAYER);

            updateHudItemSignal.Dispatch(UpdateHudItemType.HP, gameModel.playerModel.hp);
            updateHudItemSignal.Dispatch(UpdateHudItemType.EXP, gameModel.playerModel.exp);

            //Whenever a ship is created, the game is on!
            gameModel.levelInProgress = true;
            cameraEnabledSignal.Dispatch(true);
        }
Esempio n. 3
0
        public static List <string> GetAssetNames(IAssetVO asset)
        {
            List <string> list = new List <string>();

            if (asset is ProjectileTypeVO)
            {
                ProjectileUtils.AddProjectileAssetNames((ProjectileTypeVO)asset, list);
            }
            else if (asset is BuffTypeVO)
            {
                ProjectileUtils.AddBuffProjectileAssetNames((BuffTypeVO)asset, list);
            }
            return(list);
        }
Esempio n. 4
0
        private void initBackground(IAssetVO bgAssetVO)
        {
            GameObject bgStyle = Resources.Load <GameObject> (bgAssetVO.assetData.path);

            _bgGO      = (GameObject)Instantiate(bgStyle, Vector3.zero, Quaternion.identity);
            _bgGO.name = name;
            _bgGO.transform.SetParent(view.gameObject.transform, false);

            if (gameModel.isRoomLevel)
            {
                Vector3 bgPos = _bgGO.gameObject.transform.localPosition;
                bgPos.x = gameModel.playerPosX;
                _bgGO.gameObject.transform.localPosition = bgPos;
            }
        }
        public void LoadProjectileAssetsAndCreatePools(List <IAssetVO> assets)
        {
            if (assets == null || assets.Count == 0)
            {
                return;
            }
            HashSet <string> hashSet = null;
            int i     = 0;
            int count = assets.Count;

            while (i < count)
            {
                IAssetVO assetVO = assets[i];
                if (this.loadedAssets.Add(assetVO))
                {
                    List <string> assetNames = ProjectileUtils.GetAssetNames(assetVO);
                    int           j          = 0;
                    int           count2     = assetNames.Count;
                    while (j < count2)
                    {
                        string text = assetNames[j];
                        if (!this.loadedAssetNames.ContainsKey(text))
                        {
                            if (hashSet == null)
                            {
                                hashSet = new HashSet <string>();
                                hashSet.Add(text);
                            }
                            else if (!hashSet.Contains(text))
                            {
                                hashSet.Add(text);
                            }
                        }
                        j++;
                    }
                }
                i++;
            }
            if (hashSet != null)
            {
                List <string>      list  = new List <string>(hashSet);
                List <object>      list2 = new List <object>();
                List <AssetHandle> list3 = new List <AssetHandle>();
                int k      = 0;
                int count3 = list.Count;
                while (k < count3)
                {
                    list2.Add(list[k]);
                    list3.Add(AssetHandle.Invalid);
                    k++;
                }
                Service.Get <AssetManager>().MultiLoad(list3, list, new AssetSuccessDelegate(this.OnProjectileLoaded), null, list2, null, null);
                int l      = 0;
                int count4 = list.Count;
                while (l < count4)
                {
                    this.loadedAssetNames.Add(list[l], list3[l]);
                    l++;
                }
            }
        }