Exemplo n.º 1
0
        private void InstantiateCreatures()
        {
            foreach (var spawnLoc in TempData.creatureSetHashDic.Keys)
            {
                List <int> creatureHashes = new List <int>();
                int        rotTimes = TempData.creatureSetRotTimesDic[spawnLoc];
                int        cosine = (int)Mathf.Cos(rotTimes * 90 * Mathf.Deg2Rad);
                int        sine = (int)Mathf.Sin(rotTimes * 90 * Mathf.Deg2Rad);
                int        patternX, patternY;
                foreach (var ce in TempData.creatureSetHashDic[spawnLoc].GetCreatureSet().creatures)
                {
                    var cc = Instantiate(creaturePrefab, creatureHolder).GetComponent <CreatureController>();
                    patternX = ce.pattern.x * cosine + ce.pattern.y * sine;
                    patternY = -ce.pattern.x * sine + ce.pattern.y * cosine;
                    cc.InitCreature(ce.tCreature, new Location(patternX, patternY) + spawnLoc);
                    creatureHashes.Add(cc.Hash);
                    int distance = character.Loc.Distance(cc.Loc);
                    cc.SetVisual(distance < playerViewDistance);
                }
                RemainedCreatures.Add(spawnLoc, creatureHashes);

                var alertZone = new HashSet <Location>();
                foreach (var loc in spawnLoc.GetGivenDistancePoints(enemyViewDistance))
                {
                    alertZone.Add(loc);
                }
                AlertZone.Add(spawnLoc, alertZone);
            }

            if (RemainedCreatures.Count == 0 && TempData.GetAreaInfoType() == AreaType.Boss)
            {
                m_areaUIController.endStageButton.gameObject.SetActive(true);
            }
        }
Exemplo n.º 2
0
        private Location BattleCheck(Location loc)
        {
            foreach (var spawnLoc in RemainedCreatures.Keys)
            {
                var orderedHashes = new SimplePriorityQueue <int>();
                foreach (var creatureHash in RemainedCreatures[spawnLoc])
                {
                    Entity creature = creatureHash.GetEntity();
                    int    distance = character.Loc.Distance(creature.Loc);
                    creature.SetVisual(distance <= playerViewDistance);
                    orderedHashes.Enqueue(creatureHash, distance);
                }

                Location des = character.Loc.HasPath(loc) ? loc : loc.GetNearestUnblockedLocation(character.Loc);
                foreach (var step in character.Loc.GetPath(des))
                {
                    if (AlertZone[spawnLoc].Contains(step))
                    {
                        character.MoveToLocation(step, false, false);
                        foreach (var hash in RemainedCreatures[spawnLoc])
                        {
                            //Entity entity = hash.GetEntity();
                            //int distance = character.Loc.Distance(entity.Loc);
                            //entity.SetVisual(distance <= playerViewDistance);
                            hash.GetEntity().SetVisual(true);
                        }
                        GridManager.Instance.DiscoverTiles(spawnLoc);
                        BattleManager.Instance.NewBattle(RemainedCreatures[spawnLoc]);
                        RemainedCreatures.Remove(spawnLoc);
                        InBatlleCreatureSets.Add(spawnLoc);
                        MoveCheck = false;
                        return(step);
                    }
                }
            }
            character.MoveToLocation(loc, false, false);
            return(loc);
        }