コード例 #1
0
        public void Init()
        {
            if (instance == null)
            {
                instance = this;
            }

            InitItem();

            if (generateCollectibleOnStart)
            {
                GenerateCollectible();
            }
            else
            {
                for (int i = 0; i < activeItemList.Count; i++)
                {
                    if (activeItemList[i] == null)
                    {
                        activeItemList.RemoveAt(i); i -= 1;
                    }
                }
            }

            if (spawnEffect != null)
            {
                ObjectPoolManager.New(spawnEffect);
            }
        }
コード例 #2
0
ファイル: Collectible.cs プロジェクト: Hengle/TBTKPrototype
        public void Trigger(Unit unit)
        {
            if (!destroyTriggerEffect)
            {
                ObjectPoolManager.Spawn(triggerEffectObj, transform.position, Quaternion.identity);
            }
            else
            {
                ObjectPoolManager.Spawn(triggerEffectObj, transform.position, Quaternion.identity, triggerEffectDuration);
            }

            if (facAbilityIDList.Count > 0)
            {
                int facAbilityID = facAbilityIDList[Random.Range(0, facAbilityIDList.Count)];

                FactionAbility ability = AbilityManagerFaction.GetFactionAbility(facAbilityID);
                if (ability != null)
                {
                    if (!ability.requireTargetSelection)
                    {
                        AbilityManager.ApplyAbilityEffect(null, ability.Clone(), (int)ability.type);
                    }
                    else
                    {
                        AbilityManager.ApplyAbilityEffect(unit.tile, ability.Clone(), (int)ability.type);
                    }
                }
            }

            unit.ApplyEffect(CloneEffect());

            CollectibleManager.TriggerCollectible(this);

            Destroy(gameObject);
        }
コード例 #3
0
 public static CollectibleManager SetInstance()                  //called in Inspector Editor
 {
     if (instance == null)
     {
         instance = (CollectibleManager)FindObjectOfType(typeof(CollectibleManager));
     }
     return(instance);
 }
コード例 #4
0
        void Awake()
        {
            instance = (GameControl)target;
            LoadDB();

            turnControl        = (TurnControl)FindObjectOfType(typeof(TurnControl));
            gridManager        = (GridManager)FindObjectOfType(typeof(GridManager));
            factionManager     = (FactionManager)FindObjectOfType(typeof(FactionManager));
            collectibleManager = (CollectibleManager)FindObjectOfType(typeof(CollectibleManager));
            settingDB          = SettingDB.LoadDB();

            InitLabel();
        }
コード例 #5
0
        void Awake()
        {
            instance = (GridManager)target;
            instance.SetInstance();

            //factionManager = (FactionManager)FindObjectOfType(typeof(FactionManager));
            factionManager     = FactionManager.SetInstance();
            collectibleManager = CollectibleManager.SetInstance();

            LoadDB();

            InitLabel();
        }
コード例 #6
0
        public IEnumerator _EndTurn()
        {
            Debug.Log("end turn");

            ClearSelectedUnit();

            float delay = CollectibleManager.NewTurn();

            if (delay > 0)
            {
                yield return(new WaitForSeconds(delay));
            }

            TurnControl.EndTurn();
        }
コード例 #7
0
 void Awake()
 {
     instance = (CollectibleManager)target;
     LoadDB();
 }
コード例 #8
0
        void Awake()
        {
            instance = this;

            TBData.ClearEndData();

            SettingDB settingDB = InitSetting();

            if (enableCover)
            {
                CoverSystem.SetFullCoverDodgeBonus(fullCoverBonus);
                CoverSystem.SetHalfCoverDodgeBonus(halfCoverBonus);
                CoverSystem.SetExposedCritChanceBonus(exposedCritBonus);
            }

            //get the instance of each component and initiate them, the order in which these component matters

            PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager));

            if (perkManager != null)
            {
                perkManager.Init();
            }

            AbilityManagerUnit abManagerUnit = (AbilityManagerUnit)FindObjectOfType(typeof(AbilityManagerUnit));

            if (abManagerUnit != null)
            {
                abManagerUnit.Init();
            }

            AbilityManagerFaction abManagerFac = (AbilityManagerFaction)FindObjectOfType(typeof(AbilityManagerFaction));

            if (abManagerFac != null)
            {
                abManagerFac.Init();
            }

            TurnControl turnControl = (TurnControl)FindObjectOfType(typeof(TurnControl));

            turnControl.Init();

            if (settingDB != null)
            {
                turnControl.turnMode  = settingDB.turnMode;
                turnControl.moveOrder = settingDB.moveOrder;
            }

            GridManager gridManager = (GridManager)FindObjectOfType(typeof(GridManager));

            if (settingDB != null)
            {
                gridManager.generateGridOnStart = settingDB.generateGridOnStart;
            }
            gridManager.Init();

            FactionManager factionManager = (FactionManager)FindObjectOfType(typeof(FactionManager));

            if (settingDB != null)
            {
                factionManager.generateUnitOnStart = settingDB.generateUnitOnStart;
            }
            factionManager.Init();

            CollectibleManager collectibleManager = (CollectibleManager)FindObjectOfType(typeof(CollectibleManager));

            if (settingDB != null)
            {
                collectibleManager.generateCollectibleOnStart = settingDB.generateCollectibleOnStart;
            }
            collectibleManager.Init();

            GridManager.SetupGridForFogOfWar();

            OverlayManager overlayManager = (OverlayManager)FindObjectOfType(typeof(OverlayManager));

            overlayManager.Init();

            defaultShootObject = Resources.Load("ScenePrefab/DefaultShootObject", typeof(GameObject)) as GameObject;

            gamePhase = _GamePhase.Initialization;
        }
コード例 #9
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUI.changed = false;

            Undo.RecordObject(this, "GridManagerEditor");
            Undo.RecordObject(instance, "GridManager");

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (instance.grid != null)
            {
                if (instance.grid.IsInitiated())
                {
                    string text = "";
                    text += "Current Grid Dimension : " + instance.grid.GetWidth() + "x" + instance.grid.GetLength() + "\n";
                    text += "Current Grid Tile Size    :  " + instance.grid.GetTileSize().ToString();
                    EditorGUILayout.HelpBox(text, MessageType.Info);
                }
                else
                {
                    EditorGUILayout.HelpBox("Grid properties is not properly set.\nPlease regenerate the grid", MessageType.Warning);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("There's no grid", MessageType.Warning);
            }

            GUILayout.Label("________________________________________________________________________________________________________", GUILayout.Width(editorWidth - 30));
            EditorGUILayout.Space();

            int tileType = (int)instance.tileType;

            cont  = new GUIContent("Tile Type:", "The type of grid to use (Hex or Square)");
            contL = new GUIContent[tileTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(tileTypeLabel[i], tileTypeTooltip[i]);
            }
            tileType          = EditorGUILayout.Popup(cont, tileType, contL);
            instance.tileType = (_TileType)tileType;

            int gridColliderType = (int)instance.gridColliderType;

            cont  = new GUIContent("Grid Collider Type:", "The type of collider to use (The collider are used for cursor detection)");
            contL = new GUIContent[gridColliderTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(gridColliderTypeLabel[i], gridColliderTypeTooltip[i]);
            }
            gridColliderType          = EditorGUILayout.Popup(cont, gridColliderType, contL);
            instance.gridColliderType = (GridManager._GridColliderType)gridColliderType;

            cont = new GUIContent("Diagonal Neighbour:", "Check to enable diagonal neighbour\nOnly applicable when using square tile");
            if (instance.grid.GetTileType() != _TileType.Square)
            {
                EditorGUILayout.LabelField(cont, new GUIContent("-"));
            }
            else
            {
                instance.enableDiagonalNeighbour = EditorGUILayout.Toggle(cont, instance.enableDiagonalNeighbour);
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showGridSetting = EditorGUILayout.Foldout(showGridSetting, "Show Grid Setting");                  //, foldoutStyle);
            EditorGUILayout.EndHorizontal();

            if (showGridSetting)
            {
                cont           = new GUIContent("   - Grid Width:", "The number of tile in the grid in x-axis");
                instance.width = EditorGUILayout.IntField(cont, instance.width);

                cont            = new GUIContent("   - Grid Length:", "The number of tile in the grid in z-axis");
                instance.length = EditorGUILayout.IntField(cont, instance.length);

                cont = new GUIContent("   - Tile Size:", "The space occupied by of the individual tile in the grid");
                instance.tileSize = EditorGUILayout.FloatField(cont, instance.tileSize);

                cont = new GUIContent("   - GridToTileRatio:", "The ratio of the actual space each individual tile are occupying to the visible size of the individual tile\n\nThis is used to give some spacing between each tile when visualizing the grid\nRecommended value are 1 to 1.2");
                instance.gridToTileRatio = EditorGUILayout.FloatField(cont, instance.gridToTileRatio);

                cont = new GUIContent("   - UnwalkableRate:", "The percentage of the unwalkable tile on the grid. Takes value from 0-1 with 0.25 means 25% of the grid will not be walkabe");
                instance.unwalkableRate = EditorGUILayout.FloatField(cont, instance.unwalkableRate);
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showGridPrefab = EditorGUILayout.Foldout(showGridPrefab, "Show Grid Prefab Assignment Setting");                  //, foldoutStyle);
            EditorGUILayout.EndHorizontal();

            if (showGridPrefab)
            {
                cont = new GUIContent("   - Wall H:", "Wall prefab with full-cover. This applies to both hex and square grid");
                instance.obstacleWallH = (Transform)EditorGUILayout.ObjectField(cont, instance.obstacleWallH, typeof(Transform), true);
                cont = new GUIContent("   - Wall F:", "Wall prefab with half-cover. This applies to both hex and square grid");
                instance.obstacleWallF = (Transform)EditorGUILayout.ObjectField(cont, instance.obstacleWallF, typeof(Transform), true);

                cont = new GUIContent("   - Obstacle Hex H:", "Obstacle prefab with full-cover for hex-grid");
                instance.obstacleHexF = (Transform)EditorGUILayout.ObjectField(cont, instance.obstacleHexF, typeof(Transform), true);
                cont = new GUIContent("   - Obstacle Hex F:", "Obstacle prefab with half-cover for hex-grid");
                instance.obstacleHexH = (Transform)EditorGUILayout.ObjectField(cont, instance.obstacleHexH, typeof(Transform), true);

                cont = new GUIContent("   - Obstacle Sq H:", "Obstacle prefab with full-cover for square-grid");
                instance.obstacleSqF = (Transform)EditorGUILayout.ObjectField(cont, instance.obstacleSqF, typeof(Transform), true);
                cont = new GUIContent("   - Obstacle Sq F:", "Obstacle prefab with half-cover for square-grid");
                instance.obstacleSqH = (Transform)EditorGUILayout.ObjectField(cont, instance.obstacleSqH, typeof(Transform), true);
            }

            EditorGUILayout.Space();

            if (!Application.isPlaying)
            {
                if (GUILayout.Button("Generate Grid"))
                {
                    instance.GenerateGrid();
                    EditorUtility.SetDirty(instance);
                }
                if (GUILayout.Button("Generate Unit"))
                {
                    FactionManager.GenerateUnit();
                    EditorUtility.SetDirty(instance);
                }
                if (GUILayout.Button("Generate Collectible"))
                {
                    CollectibleManager.GenerateCollectible();
                    EditorUtility.SetDirty(instance);
                }
            }

            EditorGUILayout.Space();

            DrawGridEditor();

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }