Beispiel #1
0
    private void Start()
    {
        photonview = this.transform.GetChild(0).GetComponent <PhotonView>();

        PlayerObj.SetActive(true);
        //rvocontroller = GetComponentInChildren<Pathfinding.RVO.RVOController>();
        seeker             = GetComponentInChildren <Pathfinding.Seeker>();
        aipath             = GetComponentInChildren <Pathfinding.AIPath>();
        funnelmodifier     = GetComponentInChildren <Pathfinding.FunnelModifier>();
        aidestinatonsetter = GetComponentInChildren <Pathfinding.AIDestinationSetter>();
        playermouse        = GetComponentInChildren <PlayerMouse>();
        rigidbody          = GetComponentInChildren <Rigidbody>();
        WarFog             = PlayerObj.GetComponent <FogOfWarEntity>();
        forminimap         = transform.GetChild(2).gameObject;
        astar_target       = transform.GetChild(1).gameObject;
        splatmanager       = transform.GetChild(0).GetChild(0).gameObject;

        rigidbody.isKinematic = true;
        WarFog.enabled        = false;

        if (photonView.isMine)
        {
            PlayerObj.name = gameObject.name + "_" + PhotonNetwork.player.NickName;
        }
        else
        {
            PlayerObj.name = gameObject.name + photonView.owner.NickName;
        }

        SceneManager.activeSceneChanged += SceneLoaded;

        DontDestroyOnLoad(this);
    }
Beispiel #2
0
    private void OnTriggerExit(Collider collider)
    {
        if (FogOfWar3D.currentlyRevealed == faction)
        {
            isInTheSightRange = true;//명우가넣은거
            Check();
            //Show();
            return;
        }

        FogOfWarEntity e = collider.gameObject.GetComponent <FogOfWarEntity>();

        if (e != null)
        {
            int instanceID = e.GetInstanceID();
            for (int i = 0; i < colliderCount; i++)
            {
                if (instanceID == enteties[i].GetInstanceID())
                {
                    enteties.RemoveAt(i);
                    colliderCount--;
                }
            }

            if (colliderCount <= 0)
            {
                isInTheSightRange = false;//명우가넣은거
                Check();
                //Hide();
            }
        }
    }
Beispiel #3
0
    private void OnEnable()
    {
        audio               = GetComponent <AudioSource>();
        fog                 = GetComponent <FogOfWarEntity>();
        mesh                = GetComponent <SkinnedMeshRenderer>();
        myChampionData      = GetComponent <ChampionData>();
        myChampionAnimation = GetComponent <ChampionAnimation>();
        ChampHP             = transform.GetComponent <ChampionHP>();
        icon                = transform.parent.GetComponentInChildren <ChampionIcon>().gameObject;
        rigidbody           = GetComponent <Rigidbody>();
        myPhotonView        = GetComponent <PhotonView>();
        if (myPhotonView.owner.GetTeam().ToString().Equals("blue"))
        {
            Team = "Blue";
        }
        if (photonView.owner.Equals(PhotonNetwork.player) && SceneManager.GetActiveScene().name.Equals("Selection"))
        {
            ChampionSound.instance.SelectionVoice(PlayerData.Instance.championName);
        }

        if (!myPhotonView.isMine) // 사운드
        {
            audio.volume       = 0.5f;
            audio.loop         = false;
            audio.spatialBlend = 1f;
            audio.rolloffMode  = AudioRolloffMode.Linear;
            audio.maxDistance  = 20f;
        }
    }
Beispiel #4
0
    private void Awake()
    {
        ingameManager      = GameObject.FindGameObjectWithTag("InGameManager").GetComponent <InGameManager>();
        mesh               = GetComponentInChildren <SkinnedMeshRenderer>();
        fog                = GetComponent <FogOfWarEntity>();
        minHP              = transform.GetComponent <MinionHP>();
        TheAIDest          = gameObject.GetComponent <AIDestinationSetter>();
        minAtk             = transform.GetComponentInChildren <MinionAtk>();
        Audio              = GetComponentInChildren <AudioSource>();
        Audio.minDistance  = 1.0f;
        Audio.maxDistance  = 10.0f;
        Audio.volume       = 1f;
        Audio.spatialBlend = 0.5f;
        Audio.rolloffMode  = AudioRolloffMode.Linear;
        if (minAtk == null)
        {
            print("minatk is null");
        }
        TheAIPath = gameObject.GetComponent <AIPath>();

        if (!cursor)
        {
            cursor = GameObject.FindGameObjectWithTag("MouseCursor").GetComponent <AOSMouseCursor>();
        }
    }
Beispiel #5
0
 private void Awake()
 {
     mainCamera     = Camera.main;
     myCanvas       = GameObject.FindGameObjectWithTag("HpbarCanvas").GetComponent <Canvas>();
     TheFogEntity   = GetComponent <FogOfWarEntity>();
     towerBehaviour = GetComponent <TowerBehaviour>();
     team           = towerBehaviour.Team.ToLower();
 }
Beispiel #6
0
 public void LateInit()
 {
     TheAIDest    = GetComponent <AIDestinationSetter>();
     TheAIPath    = GetComponent <AIPath>();
     monAtk       = GetComponentInChildren <MonsterAtk>();
     TheFogEntity = GetComponent <FogOfWarEntity>();
     monAtk.LateInit();
 }
Beispiel #7
0
    private void Awake()
    {
        mainCamera = Camera.main;
        GameObject CanvasObject = GameObject.FindGameObjectWithTag("HpbarCanvas");

        myCanvas         = CanvasObject.GetComponent <Canvas>();
        TheFogEntity     = GetComponent <FogOfWarEntity>();
        monsterBehaviour = GetComponent <MonsterBehaviour>();
    }
Beispiel #8
0
    private void Awake()
    {
        mainCamera = Camera.main;
        GameObject CanvasObject = GameObject.FindGameObjectWithTag("HpbarCanvas");

        myCanvas            = CanvasObject.GetComponent <Canvas>();
        TheFogEntity        = GetComponent <FogOfWarEntity>();
        suppressorBehaviour = GetComponent <SuppressorBehaviour>();
        team = suppressorBehaviour.Team.ToLower();
    }
Beispiel #9
0
    } // 스펠 풀링

    private void GetSpell(string spellname, Vector3 pos, string team, int viewid = 0)
    {
        GameObject obj = Spelllist[spellname][0];
        GameObject tempObj;

        if (obj == null)
        {
            return;
        }

        if (Spelllist[spellname].Count == 0)
        {
            SpellPooling(obj, spellname);
        }

        if (viewid != 0)
        {
            tempObj = PhotonView.Find(viewid).gameObject;
            if (tempObj != null)
            {
                if (spellname.Contains("Heal") || spellname.Contains("Ignite") || spellname.Contains("Ghost"))
                {
                    obj.transform.SetParent(tempObj.transform);
                    obj.transform.Rotate(Vector3.zero);
                }
                if (obj.GetComponent <WarFogForEffect>() != null && tempObj.gameObject.layer.Equals(LayerMask.NameToLayer("Champion")))
                {
                    tempFogEffect = obj.GetComponent <WarFogForEffect>();
                    tempfogEntity = tempObj.GetComponent <FogOfWarEntity>();
                    tempFogEffect.senderEntity = tempfogEntity;
                }
            }
        }
        if (!spellname.Contains("Ignite"))
        {
            if (team.Contains("red"))
            {
                obj.GetComponent <FogOfWarEntity>().faction = FogOfWar.Players.Player00;
            }
            else if (team.Contains("blue"))
            {
                obj.GetComponent <FogOfWarEntity>().faction = FogOfWar.Players.Player01;
            }
        }
        if (obj.name.Contains("Teleport") || obj.name.Contains("Recall"))
        {
            pos.y = 0.1f;
            fog.Add(obj.GetComponent <WarFogForEffect>());
        }
        Spelllist[spellname].RemoveAt(0);
        Spelllist[spellname].Add(obj);
        obj.transform.position = pos;
        obj.SetActive(true);
        obj.GetComponent <ParticleSystem>().Play();
    } // 스펠 가져옴
Beispiel #10
0
    private void Awake()
    {
        mainCamera = Camera.main;
        GameObject CanvasObject = GameObject.FindGameObjectWithTag("HpbarCanvas");

        myCanvas       = CanvasObject.GetComponent <Canvas>();
        fog            = GetComponent <FogOfWarEntity>();
        minionBehavior = GetComponent <MinionBehavior>();
        team           = minionBehavior.team.ToString().ToLower();
        ThisMinion     = this.gameObject;
        RealBar        = transform.GetChild(0).gameObject;
    }
Beispiel #11
0
    private void BasicSet()
    {
        mainCamera = Camera.main;
        GameObject CanvasObject = GameObject.FindGameObjectWithTag("HpbarCanvas");

        myCanvas         = CanvasObject.GetComponent <Canvas>();
        TheFogEntity     = GetComponent <FogOfWarEntity>();
        championData     = GetComponent <ChampionData>();
        championBehavior = GetComponent <ChampionBehavior>();
        if (!isload)
        {
            BasicSetting();
            isload = true;
        }
    }
Beispiel #12
0
    /// <summary>
    /// 해당 스크립트의 전체적인 기본 값을 설정하는 함수
    /// </summary>
    private void Init()
    {
        ingameManager = GameObject.FindGameObjectWithTag("InGameManager").GetComponent <InGameManager>();
        mesh          = GetComponentInChildren <SkinnedMeshRenderer>();
        fog           = GetComponent <FogOfWarEntity>();
        minHP         = transform.GetComponent <MinionHP>();
        minAtk        = transform.GetComponentInChildren <MinionAtk>();
        TheAIDest     = gameObject.GetComponent <AIDestinationSetter>();
        TheAIPath     = gameObject.GetComponent <AIPath>();

        if (!cursor)
        {
            cursor = GameObject.FindGameObjectWithTag("MouseCursor").GetComponent <AOSMouseCursor>();
        }

        InitAudio();
    }
Beispiel #13
0
    private void OnTriggerExit(Collider other)
    {
        string team = "";

        if (other.tag.Equals("Player"))                                     //챔피언이다.
        {
            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 (team.Equals(""))
        {
            return;
        }
        if (team.Equals(playerTeam))
        {//챔피언의 팀이 플레이어 팀이랑 같다.
            playerTeamList.Remove(other.gameObject);
            if (playerTeamList.Count < 1)
            {     //아군이 이제 부쉬에 없음
                for (int i = 0; i < enemyTeamList.Count; ++i)
                { //부쉬에 있던 적들에게 아군 나갔다고 알림
                    enemyTeamList[i].GetComponent <FogOfWarEntity>().isInTheBushMyEnemyToo = false;
                }
            }
        }
        else
        {//적이 나감. 부쉬에 있다는 신호와 부쉬 안에 아군이 있다는 신호 빼줌.
            FogOfWarEntity f = other.gameObject.GetComponent <FogOfWarEntity>();
            f.isInTheBush           = false;
            f.isInTheBushMyEnemyToo = false;
            //f.Check();
            enemyTeamList.Remove(other.gameObject);
        }
    }
Beispiel #14
0
    private void OnTriggerEnter(Collider other)
    {
        string team = "";

        if (other.tag.Equals("Player"))//챔피언일때. 나중에 태그 고쳐야하면 고쳐라.
        {
            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 (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);
        }
    }
Beispiel #15
0
    //private void TurnOnTheFogEntity(List<GameObject> list)
    //{
    //    for (int i = 0; i < list.Count; ++i)
    //    {
    //        list[i].GetComponent<FogOfWarEntity>().enabled = false;
    //        list[i].GetComponent<FogOfWarEntity>().enabled = true;
    //    }
    //}

    private void SetFogEntityFaction(List <GameObject> list, int factionNum)
    {
        //0123 => 1248
        int factionInt = 1;

        for (int i = -1; ++i < factionNum; factionInt *= 2)
        {
            ;
        }
        FogOfWar.Players faction = (FogOfWar.Players)factionInt;
        for (int i = 0; i < list.Count; ++i)
        {
            FogOfWarEntity f = list[i].GetComponent <FogOfWarEntity>();
            if (f != null)
            {
                f.enabled = false;
                f.faction = faction;
                f.enabled = true;
            }
        }
    }
Beispiel #16
0
 private void Awake()
 {
     childCount = transform.childCount;
     ps         = GetComponent <ParticleSystem>();
     warFog     = GetComponent <FogOfWarEntity>();
     if (!warFog)
     {
         this.gameObject.AddComponent <FogOfWarEntity>();
         if (warFog.gameObjects.Length == 0)
         {
             warFog.gameObjects = new GameObject[childCount];
             for (int i = 1; i < childCount; i++)
             {
                 warFog.gameObjects[i] = transform.GetChild(i).gameObject;
             }
         }
         if (PhotonNetwork.player.GetTeam().ToString().ToLower().Equals("red"))
         {
             warFog.faction = FogOfWar.Players.Player00;
         }
         else if (PhotonNetwork.player.GetTeam().ToString().ToLower().Equals("blue"))
         {
             warFog.faction = FogOfWar.Players.Player01;
         }
     }
     else
     {
         if (PhotonNetwork.player.GetTeam().ToString().ToLower().Equals("red"))
         {
             warFog.faction = FogOfWar.Players.Player00;
         }
         else if (PhotonNetwork.player.GetTeam().ToString().ToLower().Equals("blue"))
         {
             warFog.faction = FogOfWar.Players.Player01;
         }
     }
 }
Beispiel #17
0
    /// <summary>
    /// 현재 타겟을 가지고 있는지 확인 후 타겟이 없으면 타겟팅을 하는 함수
    /// </summary>
    private void CheckHasTarget()
    {
        bool isCheck = false;

        //주변에 적이 있는데 타겟이 제대로 잡히지 않았다면 타겟팅
        if (nowTarget == null)
        {
            isCheck = true;
        }
        else if (nowTarget.tag.Equals("WayPoint"))
        {
            isCheck = true;
        }
        else if (!nowTarget.activeInHierarchy)
        {
            isCheck = true;
            enemiesList.Remove(nowTarget);
        }
        else if (nowTarget.layer.Equals(LayerMask.NameToLayer("Champion")))
        {
            FogOfWarEntity fogEntity = nowTarget.GetComponent <FogOfWarEntity>();
            if (fogEntity.isInTheBush)
            {
                if (!fogEntity.isInTheBushMyEnemyToo)
                {
                    isCheck = true;
                }
            }
        }

        //주변에 적 있는데 타겟팅 안한거 확인했으니 TargetSearch 함수 호출
        if (isCheck)
        {
            TargetSearch();
        }
    }
Beispiel #18
0
    private void OnTriggerEnter(Collider collider)
    {
        if (FogOfWar3D.currentlyRevealed == faction)
        {
            isInTheSightRange = true;//명우가넣은거
            Check();
            //Show();
            return;
        }

        FogOfWarEntity e = collider.gameObject.GetComponent <FogOfWarEntity>();

        if (e != null)
        {
            if (e.faction != faction)
            {
                enteties.Add(e);
                colliderCount++;
                isInTheSightRange = true;//명우가넣은거
                Check();
                //Show();
            }
        }
    }
Beispiel #19
0
    private void OnTriggerExit(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))
        //{//챔피언의 팀이 플레이어 팀이랑 같다.
        //    playerTeamList.Remove(other.gameObject);
        //    if (playerTeamList.Count < 1)
        //    {//아군이 이제 부쉬에 없음
        //        for (int i = 0; i < enemyTeamList.Count; ++i)
        //        {//부쉬에 있던 적들에게 아군 나갔다고 알림
        //            enemyTeamList[i].GetComponent<FogOfWarEntity>().isInTheBushMyEnemyToo = false;
        //        }
        //    }
        //}
        //else
        //{//적이 나감. 부쉬에 있다는 신호와 부쉬 안에 아군이 있다는 신호 빼줌.
        //    FogOfWarEntity f = other.gameObject.GetComponent<FogOfWarEntity>();
        //    f.isInTheBush = false;
        //    f.isInTheBushMyEnemyToo = false;
        //    //f.Check();
        //    enemyTeamList.Remove(other.gameObject);
        //}

        if (team.Equals(playerTeam))
        {
            FogOfWarEntity f = other.GetComponent <FogOfWarEntity>();
            f.isInTheBush           = false;
            f.isInTheBushMyEnemyToo = false;
            f.isInTheBush           = false;
            playerTeamList.Remove(other.gameObject);
            if (playerTeamList.Count < 1)
            {
                for (int i = 0; i < enemyTeamList.Count; ++i)
                {
                    enemyTeamList[i].GetComponent <FogOfWarEntity>().isInTheBushMyEnemyToo = false;
                }
            }
        }
        else if (team.Equals(enemyTeam))
        {
            FogOfWarEntity f = other.GetComponent <FogOfWarEntity>();
            f.isInTheBush           = false;
            f.isInTheBushMyEnemyToo = false;
            f.isInTheBush           = false;
            enemyTeamList.Remove(other.gameObject);
            if (enemyTeamList.Count < 1)
            {
                for (int i = 0; i < playerTeamList.Count; ++i)
                {
                    playerTeamList[i].GetComponent <FogOfWarEntity>().isInTheBushMyEnemyToo = false;
                }
            }
        }
    }
Beispiel #20
0
    /// <summary>
    /// 리스트에 들어온 개체들의 공격 우선순위를 계산해 타겟을 설정하는 함수
    /// </summary>
    private void TargetSearch()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }

        nowTarget      = moveTarget;
        targetPriority = 6;
        float dist = 1000000, nowD;
        bool  isLockOn = false;

        for (int i = 0, tp = 6; i < enemiesList.Count; ++i)
        {
            //우선순위를 계산한다
            if (enemiesList[i].layer.Equals(LayerMask.NameToLayer("Champion")))
            {
                FogOfWarEntity fogEntity = enemiesList[i].GetComponent <FogOfWarEntity>();

                if (!fogEntity.isInTheBush)
                {
                    tp = 5;
                }
                else if (fogEntity.isInTheBushMyEnemyToo)
                {
                    tp = 5;
                }
                else
                {
                    continue;
                }
            }
            else if (enemiesList[i].tag.Equals("Minion"))
            {
                tp = 3;
            }
            else if (enemiesList[i].tag.Equals("Tower"))
            {
                if (enemiesList[i].GetComponent <TowerBehaviour>().isCanAtkMe)
                {
                    tp = 4;
                }
            }
            else if (enemiesList[i].tag.Equals("Suppressor") || enemiesList[i].tag.Equals("Nexus"))
            {
                if (enemiesList[i].GetComponent <SuppressorBehaviour>().isCanAtkMe)
                {
                    tp = 4;
                }
            }

            //현재의 우선순위보다 더 높은 우선순위를 가졌다면 타겟 갱신
            if (targetPriority >= tp)
            {
                isLockOn       = true;
                targetPriority = tp;
                nowD           = (enemiesList[i].transform.position - myMinion.transform.position).sqrMagnitude;

                if (dist > nowD)
                {
                    dist      = nowD;
                    nowTarget = enemiesList[i];
                }

                TheAIDest.target = nowTarget.transform;
            }
        }

        // 타겟이 없는 경우 공격에서 이동으로 전환한다.
        if (!isLockOn)
        {
            TheAIDest.target = nowTarget.transform;

            if (atkCoroutine != null)
            {
                StopCoroutine(atkCoroutine);
                atkCoroutine = null;
            }

            anim.SetBool("walking", true);

            if (TheAIPath != null)
            {
                TheAIPath.canMove   = true;
                TheAIPath.canSearch = true;
            }
        }
    }
Beispiel #21
0
    private void TargetSearch()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }

        /* 타겟팅 우선순위
         * 1. 아챔 때린 적챔
         * 2. 아챔 때린 적미니언
         * 3. 가까운 적미니언
         * 4. 가까운 적포탑
         * 5. 가까운 적챔피언
         */
        nowTarget      = MoveTarget;
        targetPriority = 6;
        float dist = 1000000, nowD;
        bool  isLockOn = false;

        for (int i = 0, tp = 6; i < enemiesList.Count; ++i)
        {
            if (enemiesList[i].layer.Equals(LayerMask.NameToLayer("Champion")))
            {
                FogOfWarEntity f = enemiesList[i].GetComponent <FogOfWarEntity>();
                //if (enemiesList[i].GetComponent<FogOfWarEntity>().isCanTargeting)
                if (!f.isInTheBush)
                {
                    tp = 5;
                }
                else if (f.isInTheBushMyEnemyToo)
                {
                    tp = 5;
                }
                else
                {
                    continue;
                }
            }
            else if (enemiesList[i].tag.Equals("Minion"))
            {
                tp = 3;
            }
            else if (enemiesList[i].tag.Equals("Tower"))
            {
                if (enemiesList[i].GetComponent <TowerBehaviour>().isCanAtkMe)
                {
                    tp = 4;
                }
            }
            else if (enemiesList[i].tag.Equals("Suppressor") || enemiesList[i].tag.Equals("Nexus"))
            {
                if (enemiesList[i].GetComponent <SuppressorBehaviour>().isCanAtkMe)
                {
                    tp = 4;
                }
            }
            if (targetPriority >= tp)
            {
                isLockOn       = true;
                targetPriority = tp;
                nowD           = (enemiesList[i].transform.position - myMinion.transform.position).sqrMagnitude;
                if (dist > nowD)
                {
                    dist      = nowD;
                    nowTarget = enemiesList[i];
                }
                TheAIDest.target = nowTarget.transform;
            }
        }
        if (!isLockOn)
        {
            TheAIDest.target = nowTarget.transform;
            if (AtkCoroutine != null)
            {//공격을 끈 후
                StopCoroutine(AtkCoroutine);
                AtkCoroutine = null;
            }
            Anim.SetBool("walking", true);//이동을 풀어준다.
            if (TheAIPath != null)
            {
                TheAIPath.canMove   = true;
                TheAIPath.canSearch = true;
            }
        }
    }
Beispiel #22
0
    private void Update()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        if (atkDelayTime > 0)
        {
            atkDelayTime -= Time.deltaTime;
            if (!isAtkDelayTime)
            {
                isAtkDelayTime = true;
            }
        }
        else
        {
            if (isAtkDelayTime)
            {
                isAtkDelayTime = false;
            }
        }

        if (helpTime > 0 && targetPriority < 3)
        {//주변에 아군 챔피언이 맞았으면 헬프타임이 3이 된다.
            helpTime -= Time.deltaTime;
            if (helpTime <= 0)
            {     //헬프타임이 처음 뜬 지 3초가 지났다
                if (!enemiesList.Contains(nowTarget))
                { //적이 범위를 벗어났다 => 타겟 초기화
                    nowTarget = null;
                }
                else
                { //적이 범위 안에 아직 있다 => 3초 더 팬다
                    helpTime += 3;
                }
            }
        }
        if (enemiesList.Count > 0)
        {
            bool check = false;
            if (nowTarget == null)
            {//주변에 적이 있는데 내가 타겟이 아예 없다 = 타겟팅 하자
                check = true;
            }
            else if (nowTarget.tag.Equals("WayPoint"))
            {//주변에 적이 있는데 잡은 타겟이 웨이포인트거나, 액티브 펄스다 = 타겟팅 하자
                check = true;
            }
            else if (!nowTarget.activeInHierarchy)
            {
                check = true;
                enemiesList.Remove(nowTarget);
            }
            else if (nowTarget.layer.Equals(LayerMask.NameToLayer("Champion")))
            {
                FogOfWarEntity f = nowTarget.GetComponent <FogOfWarEntity>();
                if (f.isInTheBush)
                {
                    if (!f.isInTheBushMyEnemyToo)
                    {
                        check = true;
                    }
                }
            }
            if (check)
            {//주변에 적 있는데 타겟팅 안한거 확인. 타겟팅 하자.
                TargetSearch();
            }

            if (nowTarget.tag != "WayPoint")
            {//현재 타겟이 웨이포인트가 아닌 공격할 대상이다.
                if (TheAIPath == null)
                {
                    TheAIPath = myMinion.GetComponent <AIPath>();
                }
                //float a = Vector3.Distance(nowTarget.transform.position, myMinion.transform.position);
                //if ((nowTarget.transform.position - myMinion.transform.position).sqrMagnitude > AtkRange)
                float atkRevision = 0;
                if (nowTarget.tag.Equals("Tower") /*&& AtkRange < 5*/)
                {
                    atkRevision = 3f;
                }
                else if (nowTarget.tag.Equals("Suppressor") /*&& AtkRange < 5*/)
                {
                    atkRevision = 2.5f;
                }
                else if (nowTarget.tag.Equals("Nexus") /*&& AtkRange < 5*/)
                {
                    atkRevision = 8f;
                }
                tempVec1   = nowTarget.transform.position;
                tempVec2   = myMinion.transform.position;
                tempVec1.y = 0;
                tempVec2.y = 0;
                float distance = Vector3.Distance(tempVec1, tempVec2);
                if (distance > AtkRange + atkRevision)
                {         //공격 범위 밖에 적이 있다.
                    if (!TheAIPath.canMove)
                    {     //이동 안한다고 해뒀던 상황이면
                        if (AtkCoroutine != null)
                        { //공격을 끈 후
                            StopCoroutine(AtkCoroutine);
                            AtkCoroutine = null;
                        }
                        Anim.SetBool("walking", true);//이동을 풀어준다.
                        TheAIPath.canMove   = true;
                        TheAIPath.canSearch = true;
                    }
                }
                else
                {//공격 범위 안에 적이 있다.
                    if (!isAtkDelayTime)
                    {
                        if (TheAIPath.canMove)
                        {
                            Anim.SetBool("walking", false);
                            TheAIPath.canMove   = false;
                            TheAIPath.canSearch = false;
                            AtkCoroutine        = StartCoroutine(AtkMotion());
                            Vector3 v = nowTarget.transform.position;
                            v.y = 0;
                            myMinion.transform.DOLookAt(v, 1);
                        }
                    }
                }
            }
        }
        else if (nowTarget != null)
        {     //주변에 적이 없는데 내가 타겟을 가지고 있다.
            if (nowTarget.tag != "WayPoint")
            { //거기다 타겟이 웨이포인트가 아니다.
                if (TheAIPath == null)
                {
                    TheAIPath = myMinion.GetComponent <AIPath>();
                }
                if (!TheAIPath.canMove)
                {
                    TheAIPath.canMove   = true;
                    TheAIPath.canSearch = true;
                    Anim.SetBool("walking", true);
                    if (AtkCoroutine != null)
                    {//공격을 끈 후
                        StopCoroutine(AtkCoroutine);
                        AtkCoroutine = null;
                    }
                }
                nowTarget        = MoveTarget; // 그럼 타겟을 깔끔하게 새로 잡자.
                TheAIDest.target = nowTarget.transform;
            }
            else
            {
                if (TheAIPath == null)
                {
                    TheAIPath = myMinion.GetComponent <AIPath>();
                }
                if (!TheAIPath.canMove)
                {
                    TheAIPath.canMove   = true;
                    TheAIPath.canSearch = true;
                    Anim.SetBool("walking", true);
                    if (AtkCoroutine != null)
                    {//공격을 끈 후
                        StopCoroutine(AtkCoroutine);
                        AtkCoroutine = null;
                    }
                }
            }
        }
        else
        {
            if (MoveTarget != null)
            {
                nowTarget = MoveTarget;
                if (TheAIDest == null)
                {
                    TheAIDest = myMinion.GetComponent <AIDestinationSetter>();
                }
                TheAIDest.target = nowTarget.transform;
                if (TheAIPath == null)
                {
                    TheAIPath = myMinion.GetComponent <AIPath>();
                }
                if (!TheAIPath.canMove)
                {
                    TheAIPath.canMove   = true;
                    TheAIPath.canSearch = true;
                }
            }
        }
    }
    private void OnTriggerExit(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>();
            fogEntity.isInTheBush           = false;
            fogEntity.isInTheBushMyEnemyToo = false;
            fogEntity.isInTheBush           = false;
            playerTeamList.Remove(other.gameObject);

            //아군이 부쉬에 아무도 남지 않았는지 확인 후, 아군이 남지 않았다면 적팀에게 아군이 없음을 체크한다.
            if (playerTeamList.Count < 1)
            {
                for (int i = 0; i < enemyTeamList.Count; ++i)
                {
                    enemyTeamList[i].GetComponent <FogOfWarEntity>().isInTheBushMyEnemyToo = false;
                }
            }
        }
        else if (team.Equals(enemyTeam))
        {//적팀이 나갔다
            FogOfWarEntity fogEntity = other.GetComponent <FogOfWarEntity>();
            fogEntity.isInTheBush           = false;
            fogEntity.isInTheBushMyEnemyToo = false;
            fogEntity.isInTheBush           = false;
            enemyTeamList.Remove(other.gameObject);

            //적팀이 부쉬에 아무도 남지 않았는지 확인 후, 적팀이 남지 않았다면 아군에게 적팀이 없음을 체크한다.
            if (enemyTeamList.Count < 1)
            {
                for (int i = 0; i < playerTeamList.Count; ++i)
                {
                    playerTeamList[i].GetComponent <FogOfWarEntity>().isInTheBushMyEnemyToo = false;
                }
            }
        }
    }
    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;
        }
    }
Beispiel #25
0
    private void Update()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }

        if (nowTarget == null)
        {
            if (enemiesList.Count > 0)
            {
                int         priority = -1, nowP = -1; // 0 = champ, 1 = magician, 2 = melee, 3 = siege or super
                float       dist = 1000000, nowD;
                GameObject  temp      = null;
                Stack <int> removeNum = new Stack <int>();
                for (int i = 0; i < enemiesList.Count; ++i)
                {
                    bool c = false;
                    if (enemiesList[i] == null)
                    {
                        c = true;
                    }
                    else if (!enemiesList[i].activeInHierarchy)
                    {
                        c = true;
                    }
                    else if (enemiesList[i].transform.position.y < -50f)
                    {
                        c = true;
                    }
                    if (c)
                    {
                        removeNum.Push(i);
                    }
                }
                for (; removeNum.Count > 0; enemiesList.RemoveAt(removeNum.Pop()))
                {
                    ;
                }
                for (int i = 0; i < enemiesList.Count; ++i)
                {
                    if (enemiesList[i].tag.Equals("Minion"))
                    {
                        if (enemiesList[i].name.Contains("Siege") || enemiesList[i].name.Contains("Super"))
                        {
                            nowP = 3;
                        }
                        else if (enemiesList[i].name.Contains("Melee"))
                        {
                            nowP = 2;
                        }
                        else if (enemiesList[i].name.Contains("Magician"))
                        {
                            nowP = 1;
                        }
                    }
                    else if (enemiesList[i].layer.Equals(LayerMask.NameToLayer("Champion")))
                    {
                        FogOfWarEntity f = enemiesList[i].GetComponent <FogOfWarEntity>();
                        if (!f.isInTheBush)
                        {
                            nowP = 0;
                        }
                        else if (f.isInTheBushMyEnemyToo)
                        {
                            nowP = 0;
                        }
                        else
                        {
                            nowP = -1;
                        }
                    }
                    else
                    {
                        nowP = -1;
                    }
                    if (nowP >= priority && nowP > -1)
                    {
                        priority = nowP;
                        nowD     = (enemiesList[i].transform.position - myTower.transform.position).sqrMagnitude;
                        if (dist > nowD)
                        {
                            dist = nowD;
                            temp = enemiesList[i];
                        }
                    }
                }
                if (temp != null)
                {
                    nowTarget = temp;
                }
            }
        }
        else if (!nowTarget.activeInHierarchy)
        {
            enemiesList.Remove(nowTarget);
            nowTarget = null;
            target    = null;
            targetDir = Vector3.forward;
        }

        if (nowTarget != null)
        {
            target      = nowTarget.transform;
            targetDir   = Vector3.Normalize(target.transform.position - myTower.transform.position);
            targetDir.y = 0;

            if (nowTarget.layer.Equals(LayerMask.NameToLayer("Champion")))
            {
                if (CurTargetForSound != target)
                {
                    WarningSound();
                }
                FogOfWarEntity f = nowTarget.GetComponent <FogOfWarEntity>();
                if (f.isInTheBush)
                {
                    if (!f.isInTheBushMyEnemyToo)
                    {
                        nowTarget = null;
                        target    = null;
                        targetDir = Vector3.forward;
                    }
                }
            }
        }
        currentRotation         = Mathf.MoveTowardsAngle(currentRotation, Mathf.Atan2(targetDir.x, targetDir.z) / Mathf.PI * 180, rotationDegreePerSecond);
        transform.localRotation = Quaternion.AngleAxis(currentRotation, Vector3.forward);


        if (nowTarget == null)
        {
            if (AtkCoroutine != null)
            {
                StopCoroutine(AtkCoroutine);
                AtkCoroutine = null;
            }
        }
        else
        {
            if (AtkCoroutine == null)
            {
                AtkCoroutine = StartCoroutine(AtkMotion());
            }
        }
    }
Beispiel #26
0
    /// <summary>
    /// 공격 우선순위를 계산, 설정하는 함수
    /// </summary>
    private void SetAtkPriority()
    {
        int         priority = -1, nowPriority = -1; // 0 = champ, 1 = magician, 2 = melee, 3 = siege or super
        float       dist = 1000000, nowDist;
        GameObject  tempObj        = null;
        Stack <int> removeNumStack = new Stack <int>();

        //적 리스트에서 제거해야 할 대상을 분류한다
        for (int i = 0; i < enemiesList.Count; ++i)
        {
            bool isPush = false;

            if (enemiesList[i] == null)
            {
                isPush = true;
            }
            else if (!enemiesList[i].activeInHierarchy)
            {
                isPush = true;
            }
            else if (enemiesList[i].transform.position.y < -50f)
            {
                isPush = true;
            }

            if (isPush)
            {
                removeNumStack.Push(i);
            }
        }

        //위에서 분류한 대상을 적 리스트에서 제거한다
        for (; removeNumStack.Count > 0; enemiesList.RemoveAt(removeNumStack.Pop()))
        {
            ;
        }

        for (int i = 0; i < enemiesList.Count; ++i)
        {
            if (enemiesList[i].tag.Equals("Minion"))
            {
                if (enemiesList[i].name.Contains("Siege") || enemiesList[i].name.Contains("Super"))
                {
                    nowPriority = 3;
                }
                else if (enemiesList[i].name.Contains("Melee"))
                {
                    nowPriority = 2;
                }
                else if (enemiesList[i].name.Contains("Magician"))
                {
                    nowPriority = 1;
                }
            }
            else if (enemiesList[i].layer.Equals(LayerMask.NameToLayer("Champion")))
            {
                FogOfWarEntity fogEntity = enemiesList[i].GetComponent <FogOfWarEntity>();

                if (!fogEntity.isInTheBush)
                {
                    nowPriority = 0;
                }
                else if (fogEntity.isInTheBushMyEnemyToo)
                {
                    nowPriority = 0;
                }
                else
                {
                    nowPriority = -1;
                }
            }
            else
            {
                nowPriority = -1;
            }

            if (nowPriority >= priority && nowPriority > -1)
            {
                priority = nowPriority;
                nowDist  = (enemiesList[i].transform.position - myTower.transform.position).sqrMagnitude;

                if (dist > nowDist)
                {
                    dist    = nowDist;
                    tempObj = enemiesList[i];
                }
            }
        }

        if (tempObj != null)
        {
            nowTarget = tempObj;
        }
    }
Beispiel #27
0
    private void Update()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }

        //타겟이 없는데 적 리스트에 적이 있다면 타겟을 설정한다
        if (nowTarget == null)
        {
            if (enemiesList.Count > 0)
            {
                SetAtkPriority();
            }
        }
        else if (!nowTarget.activeInHierarchy)
        {//타겟이 죽었다면 적 리스트에서 타겟을 제거한다
            enemiesList.Remove(nowTarget);
            nowTarget       = null;
            targetTransform = null;
            targetDir       = Vector3.forward;
        }

        //타겟이 있다면 거리와 부쉬에 숨었는지 유무를 판단한다
        if (nowTarget != null)
        {
            targetTransform = nowTarget.transform;
            targetDir       = Vector3.Normalize(targetTransform.transform.position - myTower.transform.position);
            targetDir.y     = 0;

            if (nowTarget.layer.Equals(LayerMask.NameToLayer("Champion")))
            {
                if (CurTargetForSound != targetTransform)
                {
                    WarningSound();
                }

                FogOfWarEntity fogEntity = nowTarget.GetComponent <FogOfWarEntity>();

                if (fogEntity.isInTheBush)
                {
                    if (!fogEntity.isInTheBushMyEnemyToo)
                    {
                        nowTarget       = null;
                        targetTransform = null;
                        targetDir       = Vector3.forward;
                    }
                }
            }
        }

        currentRotation         = Mathf.MoveTowardsAngle(currentRotation, Mathf.Atan2(targetDir.x, targetDir.z) / Mathf.PI * 180, rotationDegreePerSecond);
        transform.localRotation = Quaternion.AngleAxis(currentRotation, Vector3.forward);

        //타겟이 있다면 공격하고, 없다면 공격을 해제한다
        if (nowTarget == null)
        {
            if (AtkCoroutine != null)
            {
                StopCoroutine(AtkCoroutine);
                AtkCoroutine = null;
            }
        }
        else if (AtkCoroutine == null)
        {
            AtkCoroutine = StartCoroutine(Attack());
        }
    }
Beispiel #28
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;
        }
    }