예제 #1
0
파일: SceneMgr.cs 프로젝트: p6352138/Assets
    // Use this for initialization
    void Start()
    {
        m_curSceneId = 1;

        //NetSessionMgr.GetInstance().Init();
        NavigationMgr.GetInstance().init(MapOrigin);
        CCearcueMgr.GetInstance().Init();

        if (m_curSceneId == GameDefine.FightSceneID)
        {
            CCearcueMgr.GetInstance().setTerrian(Terrian);
            CCearcueMgr.GetInstance().CreateCearcue(1, CCearcueType.Terrian);

            CCearcueMgr.GetInstance().setPlayer(monster4);
            CCearcueMgr.GetInstance().CreateCearcue(1, CCearcueType.Player);

            CCearcueMgr.GetInstance().testMonster1 = monster1;
            CCearcueMgr.GetInstance().testMonster2 = monster2;
            CCearcueMgr.GetInstance().testMonster3 = monster3;
            //CCearcueMgr.GetInstance().testMonster4 = monster4;

            CCearcueMgr.GetInstance().CreateCearcue(1001, CCearcueType.Monster);
            CCearcueMgr.GetInstance().CreateCearcue(1002, CCearcueType.Monster);
            CCearcueMgr.GetInstance().CreateCearcue(1003, CCearcueType.Monster);
            //CCearcueMgr.GetInstance().CreateCearcue(1004, CCearcueType.Monster);
        }

        if (isOutPutMap)
        {
            NavigationMgr.GetInstance().ImportMapData();
        }
    }
예제 #2
0
파일: CPlayer.cs 프로젝트: p6352138/Assets
        public int[] GetAttackArea()
        {
            int[] testArea = new int[8];

            int curIndex = NavigationMgr.GetInstance().GetGrid().GetPathNodeIndex(m_go.transform.localPosition);
            int column   = NavigationMgr.GetInstance().GetGrid().GetColumn(curIndex);
            int row      = NavigationMgr.GetInstance().GetGrid().GetRow(curIndex);

            testArea[0] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column - 1, row - 1);
            testArea[1] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column, row - 1);
            testArea[2] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column + 1, row - 1);
            testArea[3] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column + 1, row);
            testArea[4] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column + 1, row + 1);
            testArea[5] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column, row + 1);
            testArea[6] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column - 1, row + 1);
            testArea[7] = NavigationMgr.GetInstance().GetGrid().GetCellIndex(column - 1, row);

            int eulerIndex = (int)(m_go.transform.eulerAngles.y / 45);
            int testIndex  = 6;

            for (int i = 0; i < 3; i++)
            {
                if (eulerIndex + i >= 8)
                {
                    testIndex = eulerIndex + i - 8;
                }
                else
                {
                    testIndex = eulerIndex + i;
                }
                attackArea[i] = testArea[testIndex];
            }

            return(attackArea);
        }
예제 #3
0
파일: CTerrian.cs 프로젝트: p6352138/Assets
        public CTerrian(int id, GameObject ob)
        {
            m_BoundsList = new List <Bounds>();

            m_id = id;
            m_go = ob;

            terrain = m_go.GetComponent <Terrain>();
            BoxCollider  box;
            MeshCollider mesh;

            for (int i = 0; i < m_go.transform.FindChild("prop").childCount; i++)
            {
                box = m_go.transform.FindChild("prop").GetChild(i).GetComponent <BoxCollider>();

                if (box == null)
                {
                    mesh = m_go.transform.FindChild("prop").GetChild(i).GetComponent <MeshCollider>();
                    if (mesh != null)
                    {
                        m_BoundsList.Add(mesh.bounds);
                    }
                }
                else
                {
                    m_BoundsList.Add(box.bounds);
                }
            }

            NavigationMgr.GetInstance().InitPathData(m_BoundsList);
        }
예제 #4
0
파일: SceneMgr.cs 프로젝트: p6352138/Assets
    // Update is called once per frame
    void Update()
    {
        if (isDebug)
        {
            NavigationMgr.GetInstance().showGrid();
            NavigationMgr.GetInstance().showObstacleGrid();
        }

        CCearcueMgr.GetInstance().Update(Time.deltaTime);
    }
예제 #5
0
        public void Execute(CMonster type, float time)
        {
            type.GetRenderObject().transform.LookAt(CCearcueMgr.GetInstance().player.GetRenderObject().transform.localPosition);
            type.GetRenderObject().transform.Translate(Vector3.forward * CMonsterCommon.MoveSpeed * time);

            if (NavigationMgr.GetInstance().GetGrid().GetDistance(CCearcueMgr.GetInstance().player.PositionInPathGrid, type.PositionInPathGrid) > CMonsterCommon.eyeArea)
            {
                type.m_stateMachine.ChangeState(MonsterIdelState.GetInstance());
            }
            else if (NavigationMgr.GetInstance().GetGrid().GetDistance(CCearcueMgr.GetInstance().player.PositionInPathGrid, type.PositionInPathGrid) <= CMonsterCommon.AttackArea)
            {
                type.m_stateMachine.ChangeState(MonsterIdelState.GetInstance());
            }
        }
예제 #6
0
 public void MonsterBeAttack(int[] area, EventMessageBase message)
 {
     foreach (int i in area)
     {
         foreach (CMonster monster in m_monsterEntity)
         {
             Debug.Log(NavigationMgr.GetInstance().GetGrid().GetCellIndex(monster.GetRenderObject().transform.localPosition).ToString() +
                       " =========== monster Index");
             Debug.Log(i.ToString() + " =========== attack Index");
             if (NavigationMgr.GetInstance().GetGrid().GetCellIndex(monster.GetRenderObject().transform.localPosition) == i)
             {
                 monster.OnMessage(message);
             }
         }
     }
 }
예제 #7
0
 public void Execute(CMonster type, float time)
 {
     if (NavigationMgr.GetInstance().GetGrid().GetDistance(CCearcueMgr.GetInstance().player.PositionInPathGrid, type.PositionInPathGrid) <= CMonsterCommon.eyeArea &&
         NavigationMgr.GetInstance().GetGrid().GetDistance(CCearcueMgr.GetInstance().player.PositionInPathGrid, type.PositionInPathGrid) > CMonsterCommon.AttackArea)
     {
         type.m_stateMachine.ChangeState(MonsterMoveState.GetInstance());
     }
     else if (NavigationMgr.GetInstance().GetGrid().GetDistance(CCearcueMgr.GetInstance().player.PositionInPathGrid, type.PositionInPathGrid) <= CMonsterCommon.AttackArea)
     {
         curCDTime += time;
         if (curCDTime >= CMonsterCommon.AttackCD)
         {
             curCDTime = 0;
             type.m_stateMachine.ChangeState(MonsterAttackState.GetInstance());
         }
     }
 }