コード例 #1
0
        private void Fire(ITransformComponent transform, float lauchForce)
        {
            GameObject go = _GameObjectFactory.Build(_ShellPrefab);

            go.transform.position = transform.Position;
            go.transform.rotation = transform.Rotation;
            go.GetComponent <Rigidbody>().velocity = lauchForce * transform.Forward;
            _EntityFactory.BuildEntity <ShellEntityDescriptor>(go.GetInstanceID(), new object[] { });
        }
コード例 #2
0
        public void Build(ClientPlayerSpawnData clientPlayerSpawnData, int id1)
        {
            int spawnPointIndex = UnityEngine.Random.Range(0, clientPlayerSpawnData.spawnPoints.Length);

            var go = _gameobjectFactory.Build(clientPlayerSpawnData.clientPlayerPrefab);

            PhotonView[] nViews = go.GetComponentsInChildren <PhotonView>();
            nViews[0].viewID = id1;

            var implementors = go.GetComponentsInChildren <IImplementor>();
            var initializer  = _entityFactory.BuildEntity <PlayerEntityDescriptor>(go.GetInstanceID(), implementors);

            var transform = go.transform;
            var spawnInfo = clientPlayerSpawnData.spawnPoints[spawnPointIndex];

            transform.position = spawnInfo.position;
            transform.rotation = spawnInfo.rotation;
        }
コード例 #3
0
        private void Spawn()
        {
            GameObject tankPrefab = Resources.Load <GameObject>("Tank");

            //Temp
            DataSources.SpawnDataSource spawnDataSource = Object.FindObjectOfType <DataSources.SpawnDataSource>();

            for (int i = 0; i < spawnDataSource.SpawnData.Length; i++)
            {
                //Build tank entity
                GameObject tank = _GameObjectFactory.Build(tankPrefab);

                List <IImplementor> implementors = new List <IImplementor>();
                //!!!
                tank.transform.position = spawnDataSource.SpawnData[i].SpawnPosition;
                tank.transform.rotation = spawnDataSource.SpawnData[i].SpawnRotation;
                //!!!
                TankColorImplementor colorImplementor = tank.GetComponentInChildren <TankColorImplementor>();
                colorImplementor.Color = spawnDataSource.SpawnData[i].TankColor;

                tank.GetComponents(implementors);
                implementors.Add(colorImplementor);
                implementors.Add(new TankInputImplementor());
                implementors.Add(new TankHealthImplementor(100));

                _EntityFactory.BuildEntity <TankEntityDescriptor>(tank.GetInstanceID(), implementors.ToArray());

                //Build tank weapon entity
                TankShootingImplementor weapon = tank.GetComponentInChildren <TankShootingImplementor>();
                _EntityFactory.BuildEntity <TankWeaponEntityDescriptor>(weapon.GetInstanceID(), new object[] { weapon });

                //Build tank HUD
                TankHudImplementor hudImplementor = tank.GetComponentInChildren <TankHudImplementor>();
                _EntityFactory.BuildEntity <TankHudEntityDescriptor>(hudImplementor.GetInstanceID(), new object[] { hudImplementor });
            }
        }