/// <summary>[コンストラクタ]</summary>
 public StoragePlayer(GameObject player, PlayerTerritoryIntermediary territoryIntermediary,
                      PlayerMaualCollisionAdministrator maualCollisionAdministrator, GameObject[] followPoints)
 {
     playerInfo = new PlayerInfo(player, territoryIntermediary, maualCollisionAdministrator, followPoints);
     nextCalucrateFrameCount = 0;
     isCalucrateNextUpdate   = false;
 }
 /// <summary>[コンストラクタ]</summary>
 public PlayerInfo(GameObject gameObject, PlayerTerritoryIntermediary territoryIntermediary,
                   PlayerMaualCollisionAdministrator maualCollisionAdministrator, GameObject[] followPoints)
 {
     this.gameObject                  = gameObject;
     this.territoryIntermediary       = territoryIntermediary;
     this.maualCollisionAdministrator = maualCollisionAdministrator;
     this.followPoints                = followPoints;
     instanceID = gameObject.GetInstanceID();
 }
    /// <summary>
    /// [AddPlayer]
    /// Playerを登録する
    /// 引数1: Player object
    /// 引数2: Player PlayerTerritoryIntermediary
    /// 引数3: Player PlayerMaualCollisionAdministrator
    /// 引数4: Player follow points
    /// 引数5: This main player?, default = true
    /// </summary>
    public void AddPlayer(GameObject player, PlayerTerritoryIntermediary territoryIntermediary,
                          PlayerMaualCollisionAdministrator maualCollisionAdministrator, GameObject[] followPoints, bool isMainPlayer = true)
    {
        //debug only, invalid key対策
#if UNITY_EDITOR
        if (m_players.ContainsKey(player.GetInstanceID()))
        {
            Debug.LogError("Error!! PlayerAndTerritoryManager->AddPlayer\n ContainsKey(instanceID) == true");
            return;
        }
#endif

        StoragePlayer info = new StoragePlayer(player, territoryIntermediary, maualCollisionAdministrator, followPoints);

        m_players.Add(player.GetInstanceID(), info);
        if (isMainPlayer)
        {
            mainPlayer = info.playerInfo;
        }

        ServantManager.instance.RegisterPlayer(info.playerInfo.instanceID);
    }
示例#4
0
        static void DrawGizmos(PlayerMaualCollisionAdministrator visibility, GizmoType gizmoType)
        {
            //draw?
            if (!visibility.dIsDrawGizmos)
            {
                return;
            }

            //削除確認するか経過時間で確認
            if (m_startTime + m_cCheckDestroyTime < EditorApplication.timeSinceStartup)
            {
                m_startTime = EditorApplication.timeSinceStartup;
                //削除ループ
                for (int i = 0; i < m_meshs.Count;)
                {
                    //削除可能なら削除
                    if (m_meshs[i].isDestroyReady)
                    {
                        m_meshs.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            //Distanceがおかしければ描画しない
            if (visibility.visibilityDistance <= 0.0f)
            {
                return;
            }

            //呼び出しコスト削減
            Transform  transform = visibility.transform;
            Vector3    position  = transform.position;
            Quaternion rotation  = transform.rotation;

            //視界ヒット
            if (visibility.isVisibilityStay)
            {
                Gizmos.color = m_cMeshColorHit;
            }
            //視界ヒットしていない
            else
            {
                Gizmos.color = m_cMeshColorNotHit;
            }

            //visibilityのmeshがnull -> 未設定 or 角度が変更された
            if (visibility.dGizmoMesh == null)
            {
                //初期IDでなければカウンター減算の必要があるため確認ループ
                if (visibility.dMeshID != -1)
                {
                    for (int i = 0; i < m_meshs.Count; i++)
                    {
                        //ID合致でカウンター減算, break
                        if (visibility.dMeshID == m_meshs[i].id)
                        {
                            var edit = m_meshs[i];
                            edit.counter--;
                            m_meshs[i] = edit;
                            break;
                        }
                    }
                }

                //同じ角度のMeshがないか確認するループ
                for (int i = 0; i < m_meshs.Count; i++)
                {
                    //同じ角度のMeshがある
                    if (visibility.visibilityAngle == m_meshs[i].angle)
                    {
                        //visibilityの値変更
                        visibility.dGizmoMesh = m_meshs[i].mesh;
                        visibility.dMeshID    = m_meshs[i].id;
                        //カウンター加算, break
                        var edit = m_meshs[i];
                        edit.counter++;
                        m_meshs[i] = edit;
                        break;
                    }
                }

                //Meshがまだnull -> Meshを作る必要がある
                if (visibility.dGizmoMesh == null)
                {
                    //Mesh作成
                    visibility.dGizmoMesh = CreateMesh(visibility.visibilityAngle);
                    //メッシュリストに追加
                    m_meshs.Add(new SectorMesh(visibility.dGizmoMesh, visibility.visibilityAngle, m_meshID));
                    //ID代入
                    visibility.dMeshID = m_meshID;
                    //IDを次に進める
                    m_meshID++;
                }
            }

            //Mesh描画
            Gizmos.DrawMesh(visibility.dGizmoMesh, position + m_cAdjustUp,
                            rotation * Quaternion.AngleAxis(90.0f, Vector3.forward), Vector3.one * visibility.visibilityDistance);
            Gizmos.DrawMesh(visibility.dGizmoMesh, position + m_cAdjustUp,
                            rotation * Quaternion.AngleAxis(270.0f, Vector3.forward), Vector3.one * visibility.visibilityDistance);
            Gizmos.DrawMesh(visibility.dGizmoMesh, position + m_cAdjustUp,
                            rotation, Vector3.one * visibility.visibilityDistance);
            //Sphere描画
            Gizmos.DrawWireSphere(position + m_cAdjustUp, visibility.personalDistance);
        }