コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        string team = "";

        //if (other.tag.Equals("Player"))//챔피언일때. 나중에 태그 고쳐야하면 고쳐라.
        if (other.gameObject.layer.Equals(LayerMask.NameToLayer("Champion")))
        {
            team = other.gameObject.GetComponent <ChampionBehavior>().Team;
        }
        if (other.tag.Equals("Minion"))
        {//미니언일때
            if (other.gameObject.name.Contains("Blue"))
            {
                team = "Blue";
            }
            else if (other.gameObject.name.Contains("Red"))
            {
                team = "Red";
            }
        }
        if (other.tag.Equals("Ward"))
        {
            team = other.gameObject.GetComponent <Ward>().team;
        }
        if (team.Equals(""))
        {
            return;
        }

        //if (team.Equals(playerTeam))
        //{//아군 챔피언이 부쉬에 들어왔다.
        //    if (playerTeamList.Count < 1)
        //    {//기존에는 없었던 거다.
        //        for (int i = 0; i < enemyTeamList.Count; ++i)
        //        {//적에게 부쉬에 우리팀 들어왔지롱 하고 쏴준다.
        //            enemyTeamList[i].GetComponent<FogOfWarEntity>().isInTheBushMyEnemyToo = true;
        //        }
        //    }
        //    playerTeamList.Add(other.gameObject);
        //}
        //else
        //{
        //    FogOfWarEntity f = other.gameObject.GetComponent<FogOfWarEntity>();
        //    f.isInTheBush = true;
        //    //f.Check();
        //    enemyTeamList.Add(other.gameObject);
        //}

        if (team.Equals(playerTeam))
        {//아군이 들어왔다.
            FogOfWarEntity f = other.GetComponent <FogOfWarEntity>();
            if (enemyTeamList.Count > 0)
            {
                f.isInTheBushMyEnemyToo = true;
            }
            if (playerTeamList.Count < 1)
            {                                                 //아군이 원래 이 부시에 없었다.
                for (int i = 0; i < enemyTeamList.Count; ++i) //적들에게 '자신의 적들도 부쉬에 있었다'를 켜준다.
                {
                    FogOfWarEntity nowF = enemyTeamList[i].GetComponent <FogOfWarEntity>();
                    nowF.isInTheBushMyEnemyToo = true;
                    nowF.Check();
                }
            }
            playerTeamList.Add(other.gameObject);
            f.isInTheBush = true;
        }
        else if (team.Equals(enemyTeam))
        {//적군이 들어왔다.
            FogOfWarEntity f = other.GetComponent <FogOfWarEntity>();
            if (playerTeamList.Count > 0)
            {
                f.isInTheBushMyEnemyToo = true;
            }
            if (enemyTeamList.Count < 1)
            {//적군이 원래 이 부시에 없었다.
                for (int i = 0; i < playerTeamList.Count; ++i)
                {
                    FogOfWarEntity nowF = playerTeamList[i].GetComponent <FogOfWarEntity>();
                    nowF.isInTheBushMyEnemyToo = true;
                    nowF.Check();
                }
            }
            enemyTeamList.Add(other.gameObject);
            other.GetComponent <FogOfWarEntity>().isInTheBush = true;
        }
    }
コード例 #2
0
    private void OnTriggerEnter(Collider other)
    {
        string team = "";

        //챔피언일 때 팀 저장
        if (other.gameObject.layer.Equals(LayerMask.NameToLayer("Champion")))
        {
            team = other.gameObject.GetComponent <ChampionBehavior>().team;
        }

        //미니언일때 팀 저장
        if (other.tag.Equals("Minion"))
        {
            if (other.gameObject.name.Contains("Blue"))
            {
                team = "Blue";
            }
            else if (other.gameObject.name.Contains("Red"))
            {
                team = "Red";
            }
        }

        //와드일 때 팀 저장
        if (other.tag.Equals("Ward"))
        {
            team = other.gameObject.GetComponent <Ward>().team;
        }

        //위 세 가지 경우가 아니면 신경 안써도 되는 개체니까 리턴한다.
        if (team.Equals(""))
        {
            return;
        }

        //아군이 들어왔다.
        if (team.Equals(playerTeam))
        {
            FogOfWarEntity fogEntity = other.GetComponent <FogOfWarEntity>();

            //적팀이 있는 경우 적이 있는가를 나타내는 변수를 true로 한다.
            if (enemyTeamList.Count > 0)
            {
                fogEntity.isInTheBushMyEnemyToo = true;
            }

            //아군이 원래 이 부시에 없었다.
            if (playerTeamList.Count < 1)
            {
                //적들에게도 자신의 적이 있는가 나타내는 변수를 true로 한다.
                for (int i = 0; i < enemyTeamList.Count; ++i)
                {
                    FogOfWarEntity enemyFogEntity = enemyTeamList[i].GetComponent <FogOfWarEntity>();
                    enemyFogEntity.isInTheBushMyEnemyToo = true;
                    enemyFogEntity.Check();
                }
            }

            playerTeamList.Add(other.gameObject);
            fogEntity.isInTheBush = true;
        }
        else if (team.Equals(enemyTeam))
        { //적팀이 들어왔다.
            FogOfWarEntity fogEntity = other.GetComponent <FogOfWarEntity>();

            //아군이 있는 경우 적팀에게 아군이 있는가를 체크한다.
            if (playerTeamList.Count > 0)
            {
                fogEntity.isInTheBushMyEnemyToo = true;
            }

            //적팀이 원래 이 부시에 없었다.
            if (enemyTeamList.Count < 1)
            {
                //아군에게도 적팀이 있는가를 체크한다.
                for (int i = 0; i < playerTeamList.Count; ++i)
                {
                    FogOfWarEntity nowFogEntity = playerTeamList[i].GetComponent <FogOfWarEntity>();
                    nowFogEntity.isInTheBushMyEnemyToo = true;
                    nowFogEntity.Check();
                }
            }

            enemyTeamList.Add(other.gameObject);
            other.GetComponent <FogOfWarEntity>().isInTheBush = true;
        }
    }