示例#1
0
        /// <summary>
        /// This is called on the remote when a state is entered.
        /// </summary>
        /// <param name="stateName"></param>
        /// <param name="key"></param>
        private void RemoteEnterState(string stateName, int key)
        {
            Logging.Log(this, stateName + " instanced state enter event received! key: " + key, debugLog);

            bool success;
            var  state = CachedResources.Load <State>(stateName, out success);

            if (!success)
            {
                state = CachedResources.Load <State>(StateMachineSubfolder + "/" + stateName, out success);
            }

            if (!success)
            {
                Logging.Error(this, stateName + " could not be found in a resources folder!");
                return;
            }

            state.stateManager.MuteNetworkBroadcasting = true;
            if (key == -1)
            {
                state.Enter();            //non-instanced
            }
            else
            {
                state.Enter(state.stateManager.GetByKeyId(key));  //instanced. Getting the right key by network key
            }
            state.stateManager.MuteNetworkBroadcasting = false;
        }
示例#2
0
    void Awake()
    {
        foreach (var originData in m_OriginPrefabDataList)
        {
            var prefab = CachedResources.Load <GameObject>(originData.m_PrefabPath);
            m_Origin.Add(originData.m_PrefabPath, prefab);
            var poolList = new List <GameObject>();
            m_PoolLists.Add(originData.m_PrefabPath, poolList);
            var parent = new GameObject("ObjectPool_" + originData.m_PrefabPath);
            DontDestroyOnLoad(parent);
            m_PoolObjectParents.Add(originData.m_PrefabPath, parent);

            // maxCount 分だけ、非アクティブかつシーン遷移で破棄されないインスタンスを生成する
            for (int i = 0; i < originData.m_MaxCount; i++)
            {
                var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
                if (obj != null)
                {
                    GameObject.DontDestroyOnLoad(obj);        // シーン遷移で破棄させない
                    obj.SetActive(false);                     // 非アクティブ設定
                    obj.transform.SetParent(parent.transform);
                    poolList.Add(obj);
                    var instanceID = obj.GetInstanceID();
                    m_InstanceIDToObject.Add(instanceID, obj);
                    m_InstanceIDToPrefabPath.Add(instanceID, originData.m_PrefabPath);
                }
            }
        }
    }
示例#3
0
        /// <summary>
        /// This is called on the remote when a Events.ParameterEvent is fired.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="key"></param>
        private void RemoteParameterEvent <T, TS>(string eventName, int key, T value) where TS : ParameterEvent <T, TS>
        {
            Logging.Log(this, eventName + " " + typeof(TS) + " received! key: " + key, debugLog);

            bool success;
            var  paramEvent = CachedResources.Load <TS>(eventName, out success);

            if (!success)
            {
                paramEvent = CachedResources.Load <TS>(EventSubfolder + "/" + eventName, out success);
            }

            if (!success)
            {
                Logging.Error(this, eventName + " could not be found in a resources folder!");
                return;
            }

            paramEvent.MuteNetworkBroadcasting = true;
            if (key == -1)
            {
                paramEvent.Raise(value);            //non-instanced
            }
            else
            {
                paramEvent.Raise(value, paramEvent.GetByKeyId(key));  //instanced. Getting the right key by network key
            }
            paramEvent.MuteNetworkBroadcasting = false;
        }
示例#4
0
        /// <summary>
        /// This is called on the remote when a Events.GameEvent is fired.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="key"></param>
        private void RemoteGameEvent(string eventName, int key)
        {
            Logging.Log(this, eventName + " GameEvent received! key: " + key, debugLog);

            bool success;
            var  gameEvent = CachedResources.Load <GameEvent>(eventName, out success);

            if (!success)
            {
                gameEvent = CachedResources.Load <GameEvent>(EventSubfolder + "/" + eventName, out success);
            }

            if (!success)
            {
                Logging.Error(this, eventName + " could not be found in a resources folder!");
                return;
            }

            gameEvent.MuteNetworkBroadcasting = true;
            if (key == -1)
            {
                gameEvent.Raise();            //non-instanced
            }
            else
            {
                gameEvent.Raise(gameEvent.GetByKeyId(key));  //instanced. Getting the right key by network key
            }
            gameEvent.MuteNetworkBroadcasting = false;
        }
示例#5
0
    // オブジェクト動的生成のカスタマイズ
    public GameObject Instantiate(string prefabPath, Vector3 position, Quaternion rotation)
    {
        // インスタンスを非アクティブからアクティブに変更
        GameObject go = null;

        bool find = m_Origin.ContainsKey(prefabPath);

        if (find)
        {
            foreach (GameObject obj in m_PoolLists[prefabPath])
            {
                if (obj.activeSelf)
                {
                    continue;
                }
                go = obj;
                go.SetActive(true);
                go.transform.SetParent(null);
                break;
            }
            if (go == null)
            {
                var prefab = m_Origin[prefabPath];
                go = GameObject.Instantiate(prefab, position, rotation);

                GameObject.DontDestroyOnLoad(go);                 // シーン遷移で破棄させない
                var poolList = m_PoolLists[prefabPath];
                poolList.Add(go);
                var instanceID = go.GetInstanceID();
                m_InstanceIDToObject.Add(instanceID, go);
                m_InstanceIDToPrefabPath.Add(instanceID, prefabPath);
                return(go);
            }
        }
        else
        {
            var prefab = CachedResources.Load <GameObject>(prefabPath);
            go = GameObject.Instantiate(prefab, position, rotation);
            return(go);
        }


        // アクティブに変更したインスタンスの transform 情報を設定
        if (go != null)
        {
            go.transform.position = position;
            go.transform.rotation = rotation;
        }
        return(go);
    }
示例#6
0
    void Start()
    {
        if (monobitView.isMine == false)
        {
            return;
        }

        m_DeviationalShotRotator = GetComponent <DeviationalShotRotator>();
        m_CircleHorizonMove      = GetComponent <RandomSphereHorizonMove>();
        m_AreaCollider           = GameManager.Instance.AreaCollider;
        m_AreaRadius             = m_AreaCollider.bounds.size.x * 0.5f * 0.9f;

        // ボールプレハブから剛体質量取得
        var ballPrefab = CachedResources.Load(m_BallPrefab) as GameObject;

        m_BallMass = ballPrefab.GetComponent <Rigidbody>().mass;


        RandomMove();
    }
        /// <summary>
        /// This is called on the remote when a state is entered.
        /// </summary>
        /// <param name="stateName"></param>
        /// <param name="key"></param>
        private void RemoteEnterState(string stateName, int key)
        {
            Logging.Log(this, stateName + " instanced Enter event received!", debugLog);

            bool success;
            var  state = CachedResources.Load <State>(stateName, out success);

            if (!success)
            {
                return;
            }

            state.stateManager.MuteNetworkBroadcasting = true;
            if (key == -1)
            {
                state.Enter();            //non-instanced
            }
            else
            {
                state.Enter(state.stateManager.GetByKeyId(key));  //instanced. Getting the right key by network key
            }
            state.stateManager.MuteNetworkBroadcasting = false;
        }
示例#8
0
 public Sprite GetImage()
 {
     return(CachedResources.Load <Sprite>(GetTextureKey()));
 }