示例#1
0
		//reset all selection, walkablelist and what not
		public static void ClearAllTile(){
			instance.ClearWalkableTileList();
			instance.ClearAttackableTileList();
			instance.ClearWalkableHostileList();
			
			OverlayManager.ClearSelection();
		}
示例#2
0
		void _NewHoveredTile(Tile tile){
			hoveredTile=tile;
			
			if(AbilityManager.InTargetMode()){
				SetTargetModeHoveredTile(tile);
				return;
			}
			
			bool isWalkable=walkableTileList.Contains(tile);
			
			bool isSelectedUnitTile=GameControl.GetSelectedUnit()==null ? false : true;
			if(isSelectedUnitTile) isSelectedUnitTile=GameControl.GetSelectedUnit().tile!=tile ? false : true ;
			
			//show cover overlay if cover-system is enabled
			if(GameControl.EnableCover() && (isWalkable || isSelectedUnitTile)){
				OverlayManager.ShowCoverOverlay(tile);
			}
			
			//highlight potential target for the unit to be moved into this tile
			if(isWalkable && GameControl.GetSelectedUnit().CanAttack()){
				SetWalkableHostileList(tile);
			}
			
			TBTK.OnHoverTile(tile);
		}
示例#3
0
        public static void ExitAbilityTargetMode()
        {
            if (!targetMode)
            {
                return;
            }

            TBTK.OnFactionABTargetMode();
            TBTK.OnUnitABTargetMode();                          //clear ability select mode for UI

            targetMode = false;

            instance.abilityIndex = 0;

            instance.targetModeTileList = new List <Tile>();

            OverlayManager.EnableTileCursor();
            OverlayManager.ClearAbilityTargetIndicator();
            OverlayManager.ClearAbilityRangeIndicator();

            GridManager.ClearTargetSelectMode();

            GameControl.ReselectUnit();

            if (instance.exitTargetCallBack != null)
            {
                instance.exitTargetCallBack();
            }

            TBTK.OnAbilityTargetMode(false);
        }
示例#4
0
		public static void ClearTargetSelectMode(){
			//instance.targetMode=false;
			instance.targetModeSelectCallBack=null;
			instance.targetModeHoverCallBack=null;
			instance.targetModeExitCallBack=null;
			
			OverlayManager.EnableTileCursor();
		}
示例#5
0
		//select a unit, setup the walkable, attackable tiles and what not
		public static void SelectUnit(Unit unit){
			ClearAllTile();
			//unit.tile.SetState(_TileState.Selected);
			if(unit.CanMove()) instance.SetupWalkableTileList(unit);
			if(unit.CanAttack()) instance.SetupAttackableTileList(unit);
			//instance.indicatorSelected.position=unit.tile.GetPos();
			OverlayManager.SelectUnit(unit);
		}
示例#6
0
		//function to setup and clear walkable tiles in range for current selected unit
		private void ClearWalkableTileList(){
			for(int i=0; i<walkableTileList.Count; i++){
				//walkableTileList[i].SetState(_TileState.Default);
				walkableTileList[i].hostileInRangeList=new List<Tile>();
				walkableTileList[i].distance=0;
			}
			walkableTileList=new List<Tile>();
			OverlayManager.ClearMoveableIndicator();
		}
示例#7
0
		private void SetupWalkableTileList(Unit unit){
			ClearWalkableTileList();
			List<Tile> newList=GetTilesWithinDistance(unit.tile, unit.GetEffectiveMoveRange(), true, true);
			for(int i=0; i<newList.Count; i++){
				if(newList[i].unit==null){
					walkableTileList.Add(newList[i]);
					//newList[i].SetState(_TileState.Walkable);
				}
			}
			SetupHostileInRangeforTile(unit, walkableTileList);
			OverlayManager.ShowMoveableIndicator(walkableTileList);
		}
示例#8
0
		void _ClearHoveredTile(){
			if(hoveredTile!=null){
				ClearWalkableHostileList();
			}
			
			ShowHostileIndicator(attackableTileList);
			
			hoveredTile=null;
			
			OverlayManager.HideCoverOverlay();
			
			if(AbilityManager.InTargetMode()) ClearTargetModeHoveredTile();
			
			TBTK.OnHoverTile(null);
		}
示例#9
0
		void _OnUnitDestroyed(Unit unit){
			if(GameControl.GetSelectedUnit()==null) return;
			
			Tile tile=unit.tile;
			if(attackableTileList.Contains(tile)){
				attackableTileList.Remove(tile);	//remove from target tile
				OverlayManager.RemoveHostileIndicator(tile);
			}
			
			int dist=GetDistance(tile, GameControl.GetSelectedUnit().tile, true);
			
			if(dist>0 && dist<GameControl.GetSelectedUnit().GetMoveRange()){	//if within walkable distance, add to walkable tile since the tile is now open
				walkableTileList.Add(tile);
				OverlayManager.ShowMoveableIndicator(walkableTileList);
			}
		}
示例#10
0
        public void _ActivateTargetMode(int abIndex, int AOE, _TargetType type, TargetModeCallBack sCallBack, ExitTargetModeCallBack eCallBack)
        {
            GridManager.AbilityTargetSelectMode(this.AbilityTargetSelected, this.SetTargetModeHoveredTile, this.ClearTargetModeHoveredTile);

            targetMode   = true;
            abilityIndex = abIndex;

            targetModeAOE  = AOE;
            targetModeType = type;

            targetSelectedCallBack = sCallBack;
            exitTargetCallBack     = eCallBack;

            OverlayManager.DisableTileCursor();

            TBTK.OnAbilityTargetMode(true);
        }
示例#11
0
        private void SetTargetModeHoveredTile(Tile tile)
        {
            ClearTargetModeHoveredTile();

            if (targetModeTileList.Count > 0 && !targetModeTileList.Contains(tile))
            {
                return;
            }

            targetModeHoveredTileList = new List <Tile>();
            if (targetModeAOE > 0)
            {
                targetModeHoveredTileList = GridManager.GetTilesWithinDistance(tile, targetModeAOE);
            }
            if (!targetModeHoveredTileList.Contains(tile))
            {
                targetModeHoveredTileList.Add(tile);
            }

            OverlayManager.ShowAbilityTargetIndicator(targetModeHoveredTileList);
        }
示例#12
0
		public void _FactionDeploymentComplete(){
			currentDeployableTileList=new List<Tile>();
			//for(int i=0; i<currentDeployableTileList.Count; i++) currentDeployableTileList[i].SetState(_TileState.Default);
			OverlayManager.ClearDeploymentIndicator();
		}
示例#13
0
		public void _DeployingFaction(int factionID){
			currentDeployableTileList=_GetDeployableTileList(factionID);
			//for(int i=0; i<currentDeployableTileList.Count; i++) currentDeployableTileList[i].SetState(_TileState.Range);
			OverlayManager.ShowDeploymentIndicator(currentDeployableTileList);
		}
示例#14
0
		public void ShowHostileIndicator(List<Tile> list){ OverlayManager.ShowHostileIndicator(list); }
示例#15
0
		public void ClearHostileIndicator(){ OverlayManager.ClearHostileIndicator(); }
示例#16
0
 private void ClearTargetModeHoveredTile(Tile tile = null)
 {
     OverlayManager.ClearAbilityTargetIndicator();
 }
示例#17
0
        //~ public void ActivateTargetModeUnit(Tile tile, int range, int AOE, bool normalAttack, bool requireDirectLOS, _TargetType type, TargetModeCallBack sCallBack, TargetModeCallBack eCallBack){
        public void ActivateTargetModeUnit(Tile tile, UnitAbility ability, int abIndex, TargetModeCallBack sCallBack, ExitTargetModeCallBack eCallBack)
        {
            TBTK.OnUnitABTargetMode(abIndex);
            _ActivateTargetMode(abIndex, ability.GetAOERange(), ability.targetType, sCallBack, eCallBack);

            if (!ability.AttackInLine())
            {
                if (!ability.normalAttack)
                {
                    if (targetModeType == _TargetType.EmptyTile)
                    {
                        targetModeTileList = GridManager.GetTilesWithinDistance(tile, ability.GetRange(), true);
                    }
                    else
                    {
                        targetModeTileList = GridManager.GetTilesWithinDistance(tile, ability.GetRange());
                    }
                }
                else
                {
                    targetModeTileList = new List <Tile>();
                    List <Tile> tilesInRangeList = GridManager.GetTilesWithinDistance(tile, ability.GetRange());

                    int         sight = tile.unit.GetSight();
                    List <Unit> allFriendlyUnitList = FactionManager.GetAllUnitsOfFaction(tile.unit.factionID);

                    for (int i = 0; i < tilesInRangeList.Count; i++)
                    {
                        Tile targetTile = tilesInRangeList[i];

                        if (!GameControl.EnableFogOfWar() && !GameControl.AttackThroughObstacle())
                        {
                            if (!FogOfWar.InLOS(tile, targetTile, 0))
                            {
                                continue;
                            }
                        }

                        bool inSight = GameControl.EnableFogOfWar() ? false : true;
                        if (GameControl.EnableFogOfWar())
                        {
                            if (FogOfWar.InLOS(tile, targetTile) && GridManager.GetDistance(tile, targetTile) <= sight)
                            {
                                inSight = true;
                            }
                            else if (!ability.requireDirectLOS)
                            {
                                for (int n = 0; n < allFriendlyUnitList.Count; n++)
                                {
                                    if (allFriendlyUnitList[n] == tile.unit)
                                    {
                                        continue;
                                    }
                                    if (GridManager.GetDistance(allFriendlyUnitList[n].tile, targetTile) > allFriendlyUnitList[n].GetSight())
                                    {
                                        continue;
                                    }
                                    if (FogOfWar.InLOS(allFriendlyUnitList[n].tile, targetTile))
                                    {
                                        inSight = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (inSight)
                        {
                            targetModeTileList.Add(targetTile);
                        }
                    }
                }
            }
            else
            {
                /*
                 * List<Tile> neighbourList=tile.GetNeighbourList();
                 * for(int i=0; i<neighbourList.Count; i++){
                 *      bool walkableOnly=(ability.type==UnitAbility._AbilityType.ChargeAttack);
                 *      List<Tile> tileList=GridManager.GetTilesInALine(tile, neighbourList[i], ability.GetRange(), walkableOnly);
                 *
                 *      if(tileList.Count>0){
                 *              if(targetModeType!=_TargetType.EmptyTile) targetModeTileList.Add(tileList[tileList.Count-1]);
                 *              else if (tileList[tileList.Count-1].unit==null) targetModeTileList.Add(tileList[tileList.Count-1]);
                 *      }
                 * }
                 */
            }

            //for(int i=0; i<targetModeTileList.Count; i++) targetModeTileList[i].SetState(_TileState.Range);
            OverlayManager.ShowAbilityRangeIndicator(targetModeTileList);
        }
示例#18
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;
        }
示例#19
0
 void Awake()
 {
     instance = this;
     thisT    = transform;
 }