Esempio n. 1
0
        IEnumerator Coroutine_ShootItemOnReachGoal(MazePathFinder pf)
        {
            yield return(StartCoroutine(mPSManager.Coroutine_ShowEFX(14, pf.gameObject.transform.position, 0.2f)));

            mShootItems.Remove(pf);
            Destroy(pf.gameObject);
        }
Esempio n. 2
0
        IEnumerator Coroutine_Spawn_NPC(float duration = 10.0f)
        {
            while (mFsm.GetCurrentState().ID == (int)GameState.StateID.PLAYING)
            {
                int rx = Random.Range(2, mCurrentGenerator.cols - 2);
                int ry = Random.Range(2, mCurrentGenerator.rows - 2);

                int sx = rx + mCurrentGenerator.START_X;
                int sy = ry + mCurrentGenerator.START_Y;

                Maze.Cell startCell = mCurrentGenerator.maze.GetCell(rx, ry);

                GameObject     npc = Instantiate(mNpcPrefab, new Vector3(sx, sy, 0.0f), Quaternion.identity);
                MazePathFinder mpf = npc.AddComponent <MazePathFinder>();
                mpf.mGenerator = mCurrentGenerator;
                mpf.mNpc       = npc;
                mpf.mSpeed     = 0.5f;

                // player position.
                int dx = (int)mPlayerMovement.mPlayer.transform.position.x - mCurrentGenerator.START_X;
                int dy = (int)mPlayerMovement.mPlayer.transform.position.y - mCurrentGenerator.START_Y;
                mpf.FindPath(startCell, mCurrentGenerator.maze.GetCell(dx, dy));
                mpf.onReachGoal += NPCOnReachGoal;

                mNPCs.Add(mpf);
                yield return(new WaitForSeconds(duration));
            }
        }
Esempio n. 3
0
        public void Shoot()
        {
            if (mNPCs.Count == 0)
            {
                return;
            }
            if (mAmmoScore < 2)
            {
                return;
            }

            mAmmoScore -= 2;

            // npc pos
            int ex = (int)mNPCs[0].transform.position.x - mCurrentGenerator.START_X;
            int ey = (int)mNPCs[0].transform.position.y - mCurrentGenerator.START_Y;

            // player position.
            int dx = (int)mPlayerMovement.mPlayer.transform.position.x - mCurrentGenerator.START_X;
            int dy = (int)mPlayerMovement.mPlayer.transform.position.y - mCurrentGenerator.START_Y;

            GameObject     npc = Instantiate(mShootItemPrefab, mPlayerMovement.mPlayer.transform.position, Quaternion.identity);
            MazePathFinder mpf = npc.AddComponent <MazePathFinder>();

            mpf.mGenerator = mCurrentGenerator;
            mpf.mNpc       = npc;
            mpf.mSpeed     = 10.0f;

            // attach a PS to it.
            Transform obj = Instantiate(mShootEffectPrefab, npc.transform.position, Quaternion.identity);

            obj.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            obj.SetParent(npc.transform);

            // apply the path finder.
            mpf.FindPath(mCurrentGenerator.maze.GetCell(dx, dy), mCurrentGenerator.maze.GetCell(ex, ey));
            mShootItems.Add(mpf);

            mpf.onReachGoal += ShootItemOnReachGoal;
        }
Esempio n. 4
0
        void HandleMouseClick()
        {
            if (mMenuHandler.mShowingExitPopup)
            {
                return;
            }

            if (Input.GetMouseButtonDown(0))
            {
                Vector2 rayPos = new Vector2(
                    Camera.main.ScreenToWorldPoint(Input.mousePosition).x,
                    Camera.main.ScreenToWorldPoint(Input.mousePosition).y
                    );

                //Debug.Log("POSR: " + rayPos.x + ", " + rayPos.y);
                int x = (int)rayPos.x - mCurrentGenerator.START_X;
                int y = (int)rayPos.y - mCurrentGenerator.START_Y;
                //Debug.Log("POS : " + x + ", " + y);

                if (x < 0 || x >= mCurrentGenerator.cols || y < 0 || y >= mCurrentGenerator.rows)
                {
                    return;
                }
                Maze.Cell cell = mCurrentGenerator.maze.GetCell(x, y);

                GameObject     npc = Instantiate(mNpcPrefab, new Vector3((int)rayPos.x, (int)rayPos.y, 0.0f), Quaternion.identity);
                MazePathFinder mpf = npc.AddComponent <MazePathFinder>();
                mpf.mGenerator = mCurrentGenerator;
                mpf.mNpc       = npc;
                mpf.mSpeed     = 1.0f;

                // player position.
                int dx = (int)mPlayerMovement.mPlayer.transform.position.x - mCurrentGenerator.START_X;
                int dy = (int)mPlayerMovement.mPlayer.transform.position.y - mCurrentGenerator.START_Y;
                mpf.FindPath(cell, mCurrentGenerator.maze.GetCell(dx, dy));

                mNPCs.Add(mpf);
            }
        }
Esempio n. 5
0
 void ShootItemOnReachGoal(MazePathFinder pf)
 {
     StartCoroutine(Coroutine_ShootItemOnReachGoal(pf));
 }
Esempio n. 6
0
 void NPCOnReachGoal(MazePathFinder pf)
 {
     StartCoroutine(Coroutine_NPCOnReachGoal(pf));
 }