예제 #1
0
파일: UIMgr.cs 프로젝트: hh-pg-math/Memoria
 void Start()
 {
     _attackTracker = GetComponent <AttackTracker>();
     _spawner       = FindObjectOfType <ActorSpawner>();
     _elements      = new Dictionary <string, UIElement>();
     EventMgr.Instance.AddListener <NewTurn>(UpdateNameplates);
 }
예제 #2
0
 // Use this for initialization
 void Awake()
 {
     WorldBoardSpawner = transform.Find("Board").GetComponent <WorldBoardSpawner> ();
     ItemSpawner       = transform.Find("Board").GetComponent <ItemSpawner> ();
     ActorSpawner      = transform.Find("Actors").GetComponent <ActorSpawner> ();
     PlayerController  = transform.Find("Actors").GetComponent <PlayerController> ();
 }
예제 #3
0
        public void OnCreateFx(ActorSpawner actorSpawner)
        {
            var _actorSpawner = actorSpawner as T;

            Debug.Assert(_actorSpawner != null, $"_actorSpawner != null  {typeof(T)}.  actorSpawner={actorSpawner}  this={this}", this);

            onCreateFx(_actorSpawner);
        }
예제 #4
0
        public TileSpawner(string Name = "", Structure Structure = null, int X = 0, int Y = 0)
        {
            this.Name            = Name;
            this.X               = X;
            this.Y               = Y;
            this.Structure       = Structure;
            this.WallSpawnerDict = new Dictionary <Vector2Int, WallSpawner>(WallSpawner.EmptyWallSpawnerDict);


            if (Structure != null)
            {
                TileSpawner OldTileSpawner = Structure.TileSpawnerArray[X, Y];
                if (OldTileSpawner != null)
                {
                    //Moves the walls that where at OldTileSpaner to this tile
                    WallSpawner UpWallSpawner    = OldTileSpawner.WallSpawnerDict[Vector2Int.up];
                    WallSpawner RightWallSpawner = OldTileSpawner.WallSpawnerDict[Vector2Int.right];
                    WallSpawner DownWallSpawner  = OldTileSpawner.WallSpawnerDict[Vector2Int.down];
                    WallSpawner LeftWallSpawner  = OldTileSpawner.WallSpawnerDict[Vector2Int.left];

                    if (UpWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(UpWallSpawner, this, Vector2Int.up, UpWallSpawner.Rotation);
                    }
                    if (RightWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(RightWallSpawner, this, Vector2Int.right, RightWallSpawner.Rotation);
                    }
                    if (DownWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(DownWallSpawner, this, Vector2Int.down, DownWallSpawner.Rotation);
                    }
                    if (LeftWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(LeftWallSpawner, this, Vector2Int.left, LeftWallSpawner.Rotation);
                    }

                    //If there already was a TileSpawner at (X,Y) with an ActorSpawner move the ActorSpawner to this
                    if (OldTileSpawner.ActorSpawner != null)
                    {
                        this.ActorSpawner = OldTileSpawner.ActorSpawner;
                        OldTileSpawner.ActorSpawner.TileSpawner = this;
                        OldTileSpawner.ActorSpawner             = null;
                    }
                    //If there already was a TileSpawner at (X,Y) with a |BlockSpawner move the BlockSpawner to this
                    if (OldTileSpawner.BlockSpawner != null && (this.ActorSpawner == null || OldTileSpawner.BlockSpawner.Solid == false))
                    {
                        this.BlockSpawner = Structure.TileSpawnerArray[X, Y].BlockSpawner;
                        OldTileSpawner.BlockSpawner.TileSpawner = this;
                        OldTileSpawner.BlockSpawner             = null;
                    }
                    OldTileSpawner.Structure = null;
                }

                Structure.TileSpawnerArray[X, Y] = this;
            }
        }
예제 #5
0
        override protected void Init()
        {
            _dungeonData = FindObjectOfType <DungeonData>();

            #if DEBUG
            if (_dungeonData == null)
            {
                _dungeonData           = new DungeonData();
                _dungeonData.parameter = new DungeonParameter(4500, 4500, 0, 0, 1, 0, 0, 0, "j");
                for (int i = 0; i < _dungeonData.parameter.stocks.Length; i++)
                {
                    _dungeonData.parameter.stocks[i] = 3;
                }
                _dungeonData.SetIsBossBattle(true);
                elementalAffinity = _dungeonData.battleType.ToEnum <Element, BlockType>();
            }
            #endif

            _party = new string[]
            {
                "Amelia",
                "Dhiel",
                "Rizel",
                "Iska"
            };

            _profileType = new Type[]
            {
                typeof(Amelia),
                typeof(Dhiel),
                typeof(Rizel),
                typeof(Iska)
            };

            IsBoss = _dungeonData.isBossBattle;

            InitBattleStates();

            mainPlayer   = FindObjectOfType <MainPlayer>();
            actorList    = new List <GameObject>();
            enemyList    = new List <GameObject> ();
            currentFloor = _dungeonData.parameter.floor;

            _spawner       = FindObjectOfType <ActorSpawner>();
            _attackTracker = FindObjectOfType <AttackTracker>();
            _uiMgr         = FindObjectOfType <UIMgr> ();
            _enemies       = new EnemyPatterns();

            elementalAffinity = _dungeonData.battleType.ToEnum <Element, BlockType>();
        }
예제 #6
0
    void InitUI()
    {
        tileSelection = new TileSelction(currMap.sizeX, currMap.sizeY, pathfinding);

        Selector    = new Selector(this);
        turnManager = new TurnManager();
        spawner     = new ActorSpawner(this);
        spawner.GenerateActor(currentMission, this);

        // ui.actionMenu.InitMenu(this);
        // ui.boardManager = this;
        //ui.skillPanel.boardManager = this;

        // ui.turnOrderPanel.gameObject.SetActive(true);
        //ui.tileselctionPanel.gameObject.SetActive(true);

        ui.ToggleOnBattleUI();

        turnManager.InitTurnManager(this);

        //ui.objectivesPanel.InitMissionObjectivePanel(currentMission);
    }
 public void Init(ActorRepository repo, ActorViewModel.Factory factory, ActorSpawner spawner)
 {
     _factory = factory;
     _spawner = spawner;
     Init(repo.Actors);
 }
예제 #8
0
 public void AddSpawner(ActorSpawner spawner)
 {
     this.spawnersToAdd.Add(spawner);
 }
예제 #9
0
    protected override void _Updater(float deltaTime)
    {
        if (is_game_ended_)
        {
            return;
        }

        NavigationMap.GetInstance().OnUpdate();

        if (!navigation_map_inited_)
        {
            // get all map info to spawn monster and human
            NavigationMap.GetInstance().SpawnCreatures();
            navigation_map_inited_ = true;
        }

        base._Updater(deltaTime);

        if (IsAllActionDone())
        {
            wait_time_ = GameSettings.GetInstance().ACTION_INTERVAL;
//			DamageCharacterInWater ();
            NextTurn();
        }

        if (game_end_count_down_ > 0)
        {
            game_end_count_down_ -= deltaTime;
            if (game_end_count_down_ <= 0)
            {
                is_game_ended_ = true;
                switch (game_end_reason_)
                {
                case GameEndReason.human_rulz:

                    result_human_win.active = true;

                    break;

                case GameEndReason.monster_rulz:

                    result_monster_win.active = true;

                    break;

                case GameEndReason.time_out:
                    break;
                }
                audio_win_.Play();
                game_end_text_.text = "Score : " + CalculateScore();
                return;
            }
        }
        else
        {
            CheckIfGameEnd();
        }

        if (wait_time_ > 0)
        {
            wait_time_ -= Time.deltaTime;
        }
        else
        {
            NavigationMap.GetInstance().RefreshAll();
            // human first
            HumanDoAction();
            MonsterDoAction();
            wait_time_ = GameSettings.GetInstance().ACTION_INTERVAL;

            if (is_dino_die_sound_play_)
            {
                if (!audio_dino_die_.isPlaying)
                {
                    audio_dino_die_.Play();
                }
            }
            else if (is_human_die_sound_play_)
            {
                if (!audio_human_die_.isPlaying)
                {
                    audio_human_die_.Play();
                }
            }
            is_dino_die_sound_play_  = false;
            is_human_die_sound_play_ = false;
        }

        ActorSpawner target_spawner = null;

        for (int i = 0; i < actor_spawners_.Count; ++i)
        {
            target_spawner = actor_spawners_[i];

            GameActor actor;
            if (target_spawner.type == ActorType.human)
            {
                actor = GameActor.Create(GameSettings.GetInstance().HUMAN_PREFAB_NAME);
                ++GameStatics.human_spawned;
            }
            else
            {
                actor = GameActor.Create(GameSettings.GetInstance().MONSTER_PREFAB_NAME);
                ++GameStatics.monster_spawned;
            }
            AddEntity(actor);
            actor.transform.localPosition = new Vector3(target_spawner.column * GameSettings.GetInstance().TILE_SIZE,
                                                        target_spawner.row * GameSettings.GetInstance().TILE_SIZE,
                                                        0);
            NavigationMap.GetInstance().RegisterActor(actor);
        }
        actor_spawners_.Clear();
    }