Ejemplo n.º 1
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     for (int i = 0; i < NumWaves; i++)
     {
         PackedScene scene = (PackedScene)ResourceLoader.Load("res://Scenes/Wave" + i + ".tscn");
         Node2D      root  = (Node2D)scene.Instance();
         this.AddChild(root);
         Waves.Add(new WaveData {
             Spawns = new SpawnData[root.GetChildCount()]
         });
         int longest = 0;
         for (int idx = 0; idx < root.GetChildCount(); idx++)
         {
             SpawnData data = (SpawnData)root.GetChild(idx);
             if (data.SpawnTime >= longest)
             {
                 longest = data.SpawnTime;
             }
             Waves[i].Spawns[idx] = new SpawnData(data);
         }
         Waves[i].Length = longest;
     }
     score = 0;
     LoadHighScore();
 }
Ejemplo n.º 2
0
    void OnGUI()
    {
        EditorGUI.BeginChangeCheck();
        GUI.enabled = false;
        EditorGUILayout.Vector3Field("位置:", m_position, null);
        EditorGUILayout.Space();

        if (null == m_unitSpawner || null == m_unitSpawner.spawns)
        {
            return;
        }
        if (m_index >= m_unitSpawner.spawns.Count)
        {
            m_unitSpawner.spawns.Add(new SpawnData(m_position, null, 1, 0.1f));
        }
        SpawnData sd = m_unitSpawner.spawns[m_index];

        GUI.enabled = true;
        m_unitSpawner.spawns[m_index].maxCount        = EditorGUILayout.DelayedIntField("生产最大数:", sd.maxCount);
        m_unitSpawner.spawns[m_index].interval        = EditorGUILayout.DelayedFloatField("敌人产生间隔:", sd.interval);
        m_unitSpawner.spawns[m_index].rateOfSpawn     = EditorGUILayout.Slider("敌人产生概率(0~1):", sd.rateOfSpawn, 0, 1, null);
        m_unitSpawner.spawns[m_index].EnemeyToProduce = (GameObject)EditorGUILayout.ObjectField("预制体:", sd.EnemeyToProduce, typeof(GameObject), false, null);

        EditorGUILayout.Space();

        if (EditorGUI.EndChangeCheck())
        {
        }
        ;
    }
Ejemplo n.º 3
0
        private void MoveGreenPlatform(bool firstPlatform)
        {
            // correct map?
            if (GameHook.AccurateMapType != MapType.LookInsideCV)
            {
                PlatformErrorLabel.Content = " [!] Must be in LookInsideCV";
                return;
            }
            else
            {
                PlatformErrorLabel.Content = "";
            }

            // create platforms
            if (greenPlatforms == null)
            {
                greenPlatforms = new List <GreenPlatform>()
                {
                    new GreenPlatform(0x9E0, 0xE88), new GreenPlatform(0x9F8, 0xDB0)
                };
            }

            SpawnData spawn = new SpawnData(new Vector3f(GameHook.xPos, GameHook.yPos, GameHook.zPos), GameHook.angle);

            outputBoxPlatform.Text = $"platformLayouts.Add(new SpawnData(new Vector3f({(int)spawn.pos.X}f, {(int)spawn.pos.Y}f, {(int)spawn.pos.Z}f), new Angle({spawn.angle.angleSin:0.00}f, {spawn.angle.angleCos:0.00}f)));";
            greenPlatforms[firstPlatform ? 0 : 1].SetMemoryPos(GameHook.game, spawn);
        }
Ejemplo n.º 4
0
 public SpawnData(SpawnData copy)
 {
     this.spawnType = copy.spawnType;
     this.count     = copy.count;
     this.position  = copy.position;
     this.pleSpawn  = copy.pleSpawn;//reference is desire here
 }
Ejemplo n.º 5
0
{ protected override void OnUpdate()
  {
      var time           = Time.ElapsedTime;
      var screenOneThird = InputCatcherSetter.screenHight * 2 / 3;
      var sreenBottom    = -InputCatcherSetter.screenHight;
      var ETS            = EntityManager.GetBuffer <EntityToSpawnData>(GetSingletonEntity <EntityToSpawnData>());

      Entities
      .ForEach((ref AttackData attackPosition, in Translation translation) =>
        {
            if (attackPosition.attackPoint.x != 0 && time - attackPosition.lastAttackTime > attackPosition.fireRate)
            {
                var SD = new SpawnData();
                if (translation.Value.y <= sreenBottom + screenOneThird)
                {
                    SD.numPrefabToSpawn = 0;
                }
                else if (translation.Value.y <= sreenBottom + screenOneThird * 2)
                {
                    SD.numPrefabToSpawn = 1;
                }
                else
                {
                    SD.numPrefabToSpawn = 2;
                }
                SD.moveData = new MoveData {
                    startPosition = translation.Value, targetPosition = attackPosition.attackPoint, nonStop = 1
                };
                ETS.Add(SD);
                attackPosition.lastAttackTime = time;
            }
        }).Schedule();
      Dependency.Complete();
  }
Ejemplo n.º 6
0
    public void StartWave()
    {
        difficulty = 2 + (waveIndex * 2);
        waveTime   = waveBaseTime + difficulty;
        List <SpawnData> spawnRange = new List <SpawnData>();

        SpawnData[] newSpawnPool = new SpawnData[difficulty];
        foreach (SpawnData enemy in enemies)
        {
            if (enemy.minDifficulty <= difficulty && (enemy.maxDifficulty == 0 || enemy.maxDifficulty >= difficulty))
            {
                spawnRange.Add(enemy);
            }
        }
        for (int i = 0; i < difficulty; i++)
        {
            newSpawnPool[i] = spawnRange[Random.Range(0, spawnRange.Count)];
        }
        for (int i = 0; i < newSpawnPool.Length; i++) //initialize spawn sets
        {
            newSpawnPool[i].maxSpawnTimer = (waveTime / newSpawnPool[i].count) * (1 / (newSpawnPool[i].endDistribution - newSpawnPool[i].startDistribution));
            newSpawnPool[i].timerOffset   = 1;
        }
        currentWave = new WaveData {
            spawnPool = newSpawnPool
        };
        waveStarted   = true;
        waveCleared   = false;
        waveTimer     = waveTime;
        waveText.text = "WAVE " + waveIndex;
        menuController.SetMenu(null, true, true, false);
    }
Ejemplo n.º 7
0
        private void miSpawn_Click(object sender, System.EventArgs e)
        {
            GetDatafile msg = new GetDatafile();

            Pandora.Profile.Server.FillBoxMessage(msg);
            msg.DataType = BoxDatafile.SpawnData;

            BoxServerForm form = new BoxServerForm(msg);

            if (form.ShowDialog() == DialogResult.OK)
            {
                ReturnDatafile data = form.Response as ReturnDatafile;

                if (data != null)
                {
                    SpawnData sdata = data.Data as SpawnData;

                    if (sdata != null)
                    {
                        SpawnData.SpawnProvider           = sdata;
                        Pandora.Profile.Travel.ShowSpawns = true;
                        SpawnData.SpawnProvider.RefreshSpawns();
                    }
                }
            }
        }
Ejemplo n.º 8
0
    public static uint SpawnCharacter(BinaryReader reader)
    {
        uint  id     = reader.ReadUInt32();
        int   baseId = reader.ReadInt32();
        short rot    = reader.ReadInt16();
        float x      = reader.ReadSingle();
        float y      = reader.ReadSingle();
        float z      = reader.ReadSingle();

        List <KeyValuePair <StatType, object> > statsReceived = new List <KeyValuePair <StatType, object> >();

        for (int i = 0; i < 3; i++)
        {
            statsReceived.Add(Packets.ReadStat(reader));
        }

        Debug.Log(string.Format("Spawn character {0} {1} {2} {3}", id, x, y, z));
        var data = new SpawnData()
        {
            id    = id,
            mobId = baseId,
            rot   = rot,
            pos   = new System.Numerics.Vector3(x, y, z)
        };

        var mob = MobsManager.Instance.SpawnCharacter(data);

        foreach (var item in statsReceived)
        {
            mob.Stats.SetStat(item.Key, item.Value);
        }
        return(id);
    }
Ejemplo n.º 9
0
    IEnumerator DoSpawn()
    {
        foreach (SpawnEntity spawnEntity in this.spawnEntityArray)
        {
            CurrentSpawnEntity = spawnEntity;
//			if(spawnEntity.SpawnDelay > 0)
//			{
//				yield return new WaitForSeconds(spawnEntity.SpawnDelay);
//			}
            foreach (string spawnDataName in spawnEntity.SpawnDataNameArray)
            {
                SpawnData  spawnData   = spawnDict [spawnDataName];
                GameObject spawnedUnit = Spawn(spawnDict [spawnDataName]);
                spawnEntity.AddSpawned(spawnedUnit);
            }
            if (spawnEntity.WaitForSpawnedDieOut)
            {
                //when all spawned unit dies, turn to next SpawnEntity
                while (spawnEntity.IsSpawnedDieOut() == false)
                {
                    yield return(new WaitForSeconds(0.3333f));
                }
            }
            else
            {
                yield return(new WaitForSeconds(spawnEntity.WaitTime));
            }
            Debug.Log("SpawnEntity:" + spawnEntity.Name + " has die out!");
        }

        //all entity has completed spawning, if there're events for spawning complete, fire the events.
        if (Event_At_All_Spawned_Complete != null && Event_At_All_Spawned_Complete.Length > 0)
        {
            foreach (GameEvent e in Event_At_All_Spawned_Complete)
            {
                LevelManager.OnGameEvent(e, this);
            }
        }

        //if there're evented for spawn die out, while until all unit die out then fire the event
        if (this.Event_At_All_Spawned_DieOut != null && this.Event_At_All_Spawned_DieOut.Length > 0)
        {
            //wait for all spawn eneity die oout
            while (true)
            {
                if (this.spawnEntityArray.Count(x => x.IsSpawnedDieOut() == false) > 0)
                {
                    yield return(new WaitForSeconds(0.33333f));
                }
                else
                {
                    break;
                }
            }
            foreach (GameEvent e in Event_At_All_Spawned_DieOut)
            {
                LevelManager.OnGameEvent(e, this);
            }
        }
    }
Ejemplo n.º 10
0
 public ObstacleBase(float fpSpeedModifier, string szPrefab, SpawnData horizontalSpawnData, SpawnData verticalSpawnData)
 {
     m_fpSpeedModifier = fpSpeedModifier;
     m_szPrefab = szPrefab;
     m_horizontalSpawnData = horizontalSpawnData;
     m_verticalSpawnData = verticalSpawnData;
 }
Ejemplo n.º 11
0
	void ReadXML()
	{
		//m_enemyList = new ArrayList

		//string str = File.ReadAllText(@"d:\EnemyData.xml", Encoding.UTF8);   //读取XML文件  
		m_enemyList = new ArrayList();

		XMLParser xmlparse = new XMLParser();

		XMLNode node = xmlparse.Parse(xmlData.text);
		XMLNodeList list = node.GetNodeList("ROOT>0>table");



		for (int i = 0; i < list.Count; i++) 
		{
			string wave = node.GetValue("ROOT>0>table>" + i + ">@wave");
			//Debug.Log(wave);
			string enemyname = node.GetValue("ROOT>0>table>" + i + ">@enemyname");
			string level = node.GetValue("ROOT>0>table>" + i + ">@level");
			string wait = node.GetValue("ROOT>0>table>" + i + ">@wait");

			SpawnData data = new SpawnData();
			data.wave = int.Parse(wave);
			data.enemyName = enemyname;
			data.level = int.Parse(level);
			data.wait = float.Parse(wait);
			Debug.Log(data.enemyName);
			m_enemyList.Add(data);

		}
		 
	}
Ejemplo n.º 12
0
 public void SpawnEvent(SpawnData spawnData)
 {
     if (spawnData.spawnType == ObjectType.Player)
     {
         SpawnPlayer(spawnData);
     }
 }
    static void Main(string[] args)
    {
        // Set console title.
        Console.Title = "Epic Dragon World - Game Server";

        // Keep start time for later.
        DateTime serverLoadStart = DateTime.Now;

        // Initialize async write to disk task.
        Task.Run(() => LogManager.Init());

        Config.Load();
        DatabaseManager.Init();
        WorldManager.Init();

        SkillData.Load();
        ItemData.Load();
        NpcData.Load();
        SpawnData.Load();

        // Post info.
        Util.PrintSection("Info");
        LogManager.Log("Server loaded in " + Math.Round((DateTime.Now - serverLoadStart).TotalSeconds, 2) + " seconds.");

        // Initialize async network listening.
        Task.Run(() => GameClientNetworkListener.Init());

        // Wait.
        Console.CancelKeyPress += (sender, eArgs) =>
        {
            QUIT_EVENT.Set();
            eArgs.Cancel = true;
        };
        QUIT_EVENT.WaitOne();
    }
Ejemplo n.º 14
0
    public void CreateItemBallOne(int _idx)
    {
        cursorIndex = _idx;

        ItemBall     _prefab1, _prefab2;
        ItemBall     _scp1 = null, _scp2 = null;
        ItemBallKind _s1, _s2;
        int          _rand = Random.Range(0, 2);

        if (_rand == 0)
        {
            _prefab1 = prefabSword;
            _prefab2 = prefabSkull;
            _s1      = ItemBallKind.Sword;
            _s2      = ItemBallKind.Skull;
        }
        else
        {
            _prefab1 = prefabSkull;
            _prefab2 = prefabSword;
            _s1      = ItemBallKind.Skull;
            _s2      = ItemBallKind.Sword;
        }
        _scp1 = Instantiate(_prefab1, spawnPoint1.position, Quaternion.identity) as ItemBall;
        _scp2 = Instantiate(_prefab2, spawnPoint2.position, Quaternion.identity) as ItemBall;
        _scp1.transform.SetParent(spawnGroup);
        _scp2.transform.SetParent(spawnGroup);
        _scp1.InitInfo(_s1);
        _scp2.InitInfo(_s2);

        SpawnData _data = new SpawnData(_idx, _scp1, _scp2);

        list.Add(_data);
        MoveItemClick();
    }
Ejemplo n.º 15
0
    // 读取XML
    void ReadXML()
    {
        m_enemylist = new ArrayList();

        XMLParser xmlparse = new XMLParser();
        XMLNode   node     = xmlparse.Parse(xmldata.text);

        XMLNodeList list = node.GetNodeList("ROOT>0>table");

        for (int i = 0; i < list.Count; i++)
        {
            string wave      = node.GetValue("ROOT>0>table>" + i + ">@wave");
            string enemyname = node.GetValue("ROOT>0>table>" + i + ">@enemyname");
            string level     = node.GetValue("ROOT>0>table>" + i + ">@level");
            string wait      = node.GetValue("ROOT>0>table>" + i + ">@wait");

            SpawnData data = new SpawnData();
            data.wave      = int.Parse(wave);
            data.enemyname = enemyname;
            data.level     = int.Parse(level);
            data.wait      = float.Parse(wait);

            m_enemylist.Add(data);
        }
    }
Ejemplo n.º 16
0
        // Returns SpawnData
        public static SpawnData GetSpawnData(string scene, string spawn)
        {
            if (data == null || data.Count < 1)
            {
                MakeData();
            }

            SceneData sceneData = GetSceneData(scene);

            if (sceneData != null)
            {
                for (int i = 0; i < sceneData.spawns.Count; i++)
                {
                    SpawnData spawnData = sceneData.spawns[i];

                    if (StringHelper.DoStringsMatch(spawnData.realSpawnName, spawn))
                    {
                        return(spawnData);
                    }

                    for (int j = 0; j < spawnData.otherNames.Count; j++)
                    {
                        string otherName = spawnData.otherNames[j];

                        if (StringHelper.DoStringsMatch(otherName, spawn))
                        {
                            return(spawnData);
                        }
                    }
                }
            }

            DebugManager.LogToFile("No SpawnData was found for spawn " + spawn + ". Returning null.", LogType.Error);
            return(null);
        }
Ejemplo n.º 17
0
    //Used by DungeonManager to start mob spawning
    public void SpawnMobs(int level, int stage)
    {
        List <SpawnData> list;

        switch (Difficulty)
        {
        case DifficultyEnum.Easy:
            list = SpawnDataInfo.Easy;
            break;

        case DifficultyEnum.Normal:
            list = SpawnDataInfo.Normal;
            break;

        case DifficultyEnum.Hard:
            list = SpawnDataInfo.Hard;
            break;

        default:
            list = SpawnDataInfo.Hard;
            break;
        }

        _spawn_data     = list[level];
        _waveNumber     = 0;
        _stageNumber    = stage;
        _room_transform = _dungeon_manager.RoomStage.transform;
        StartCoroutine(StartSpawnDelay());
    }
Ejemplo n.º 18
0
    // ��ȡXML
    void ReadXML()
    {
        m_enemylist = new ArrayList();

        XMLParser xmlparse = new XMLParser();
        XMLNode node = xmlparse.Parse(xmldata.text);

        XMLNodeList list = node.GetNodeList("ROOT>0>table");
        for (int i = 0; i < list.Count; i++)
        {

            string wave = node.GetValue("ROOT>0>table>" + i + ">@wave");
            string enemyname = node.GetValue("ROOT>0>table>" + i + ">@enemyname");
            string level = node.GetValue("ROOT>0>table>" + i + ">@level");
            string wait = node.GetValue("ROOT>0>table>" + i + ">@wait");

            SpawnData data = new SpawnData();
            data.wave = int.Parse(wave);
            data.enemyname = enemyname;
            data.level = int.Parse(level);
            data.wait = float.Parse(wait);

            m_enemylist.Add(data);
        }
    }
Ejemplo n.º 19
0
        private async Task SpawnPlayer(SpawnData data, bool respawn = false)
        {
            Screen.Fading.FadeOut(0);

            API.RenderScriptCams(false, false, 0, false, false);
            Game.PlayerPed.Resurrect();

            if (!respawn)
            {
                while (!await Game.Player.ChangeModel(new Model((PedHash)Enum.Parse(typeof(PedHash), data.Skin, true))))
                {
                    await BaseScript.Delay(500);
                }
                API.SetPedDefaultComponentVariation(Game.PlayerPed.Handle);
            }

            EquipLoadout(data.Loadout);
            Game.PlayerPed.PositionNoOffset = new Vector3(data.Position.X, data.Position.Y, data.Position.Z);
            Game.PlayerPed.Rotation         = new Vector3(0, 0, data.Position.A);

            Screen.Hud.IsRadarVisible = true;

            while (!API.HasCollisionLoadedAroundEntity(Game.PlayerPed.Handle))
            {
                await BaseScript.Delay(100);
            }

            API.ClearPedTasksImmediately(Game.PlayerPed.Handle);

            Screen.Fading.FadeIn(1000);
            UpdateStartMessage(RemainingTime);
            ToggleStartMessage(true);
        }
Ejemplo n.º 20
0
    public static void create(string type, SpawnData data)
    {
        if (ShipData.enemyShips.ContainsKey(type))
        {
            Vector3  pos   = new Vector3(Mathf.Sin(data.angle), Mathf.Cos(data.angle), 0) * data.distance;
            HexaShip enemy = HexaShip.createShip(ShipData.enemyShips[type].ship, pos);
            enemy.speed = data.speed;
            enemy.type  = "enemy";

            return;
        }

        GameObject prefab = Resources.Load(type) as GameObject;

        if (prefab == null)
        {
            return;
        }

        float delay = 0f;

        for (int i = 0; i < data.count; i++)
        {
            float   angle = data.angle + (Random.Range(-10f, 10f) * Mathf.Deg2Rad);
            Vector3 pos   = new Vector3(Mathf.Sin(angle), Mathf.Cos(angle), 0) * data.distance;
            Enemy   enemy = (Instantiate(prefab, pos, Quaternion.identity) as GameObject).GetComponent <Enemy>();
            enemy.delay = delay;
            enemy.data  = data;

            delay += data.delay;
        }
    }
Ejemplo n.º 21
0
        public override void SetMemoryPos(Process game, SpawnData spawnData)
        {
            EP.DerefPointers(game);

            game.WriteBytes(EP.Pointers["Hologram"].Item2, BitConverter.GetBytes((float)spawnData.pos.X));
            game.WriteBytes(EP.Pointers["Hologram"].Item2 + 4, BitConverter.GetBytes((float)spawnData.pos.Y));
            game.WriteBytes(EP.Pointers["Hologram"].Item2 + 8, BitConverter.GetBytes((float)spawnData.pos.Z));

            // Particles
            game.WriteBytes(EP.Pointers["Particles"].Item2, BitConverter.GetBytes((float)spawnData.pos.X));
            game.WriteBytes(EP.Pointers["Particles"].Item2 + 4, BitConverter.GetBytes((float)spawnData.pos.Y));
            game.WriteBytes(EP.Pointers["Particles"].Item2 + 8, BitConverter.GetBytes((float)spawnData.pos.Z));

            // CenterBox
            game.WriteBytes(EP.Pointers["CenterBox"].Item2, BitConverter.GetBytes((float)spawnData.pos.X));
            game.WriteBytes(EP.Pointers["CenterBox"].Item2 + 4, BitConverter.GetBytes((float)spawnData.pos.Y));
            game.WriteBytes(EP.Pointers["CenterBox"].Item2 + 8, BitConverter.GetBytes((float)spawnData.pos.Z));
            // Hitbox
            game.WriteBytes(EP.Pointers["Box"].Item2, BitConverter.GetBytes((float)spawnData.pos.X - BoxOffset.X));
            game.WriteBytes(EP.Pointers["Box"].Item2 + 4, BitConverter.GetBytes((float)spawnData.pos.Y - BoxOffset.Y));
            game.WriteBytes(EP.Pointers["Box"].Item2 + 8, BitConverter.GetBytes((float)spawnData.pos.Z - BoxOffset.Z));
            game.WriteBytes(EP.Pointers["Box"].Item2 + 12, BitConverter.GetBytes((float)spawnData.pos.X + BoxOffset.X));
            game.WriteBytes(EP.Pointers["Box"].Item2 + 16, BitConverter.GetBytes((float)spawnData.pos.Y + BoxOffset.Y));
            game.WriteBytes(EP.Pointers["Box"].Item2 + 20, BitConverter.GetBytes((float)spawnData.pos.Z + BoxOffset.Z));
        }
Ejemplo n.º 22
0
    public void DrawLine(Vector2 a, Vector2 b)
    {
        if (selectedPrefab == null)
        {
            return;
        }
        List <SpawnData> newList = new List <SpawnData>();

        foreach (SpawnData data in Inspecting.spawns)
        {
            newList.Add(data);
        }
        undoStack.Push(newList);
        for (int i = 0; i < bCount; i++)
        {
            float      lerpValue = (float)i / (float)(bCount - 1);
            Vector2    pos       = Vector2.Lerp(a, b, lerpValue);
            GameObject bullet    = Instantiate(selectedPrefab, pos, Quaternion.identity);
            SpawnData  newSpawn  = new SpawnData();
            newSpawn.name     = selectedPrefab.name;
            newSpawn.position = pos;
            dict.Add(bullet, newSpawn);
            Inspecting.spawns.Add(newSpawn);
            list.Add(bullet);
        }
        EditorUtility.SetDirty(Inspecting);
    }
Ejemplo n.º 23
0
    private void StartNewWave()
    {
        WaveNumber++;
        totalProbability = 0;
        enemySpawned     = 0;
        spawning         = true;
        Debug.Log($"Starting new wave n° {WaveNumber}");

        //Update spawn rate for each enemy type
        foreach (EnemyProbability prob in SpawnData.enemyRates)
        {
            if (prob.startWave >= WaveNumber)
            {
                if (prob.startWave != WaveNumber)
                {
                    prob.Increment();
                }
                prob.CurrentProbability = Random.Range(prob.minProbability, prob.maxProbability);
                totalProbability       += prob.CurrentProbability;
            }
        }

        //Update spawn amount
        SpawnData.ComputeAmount(WaveNumber);
        Debug.Log($"Preparing to spawn {SpawnData.EnemyAmount} enemies");
        //Spawn enemies
        InvokeRepeating(nameof(SpawnEnemy), 0, SpawnData.spawnRate);
    }
Ejemplo n.º 24
0
    //MasterClient spawns a new enemy at spwan rate
    void SpawnRandomEnemy()
    {
        //only master client can spawn enemies
        if (!PhotonNetwork.IsMasterClient)
        {
            return;
        }

        //create SpawnData
        var data = new SpawnData();

        data.type     = GetSpawnableType();
        data.target_x = Random.Range(minX, maxX);
        data.target_y = Random.Range(minY, maxY);
        int rand = Random.Range(0, transform.childCount); //this game objects children are the start positions for the spawnable

        data.startingPosition = rand;

        //pack SpawnData into a quaternion and send it as an event
        Quaternion quat;

        quat.x = (float)data.type;
        quat.y = (float)data.target_x;
        quat.z = (float)data.target_y;
        quat.w = (float)data.startingPosition;
        object content = (object)quat;

        RaiseEventOptions options = new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        };

        PhotonNetwork.RaiseEvent((byte)EventCodes.SpawnableSpawned, content, options, SendOptions.SendReliable);
    }
Ejemplo n.º 25
0
    protected override void OnUpdate()
    {
        var ETS = EntityManager.GetBuffer <EntityToSpawnData>(GetSingletonEntity <EntityToSpawnData>());

        Entities
        .WithAll <EnemyTag>()
        .ForEach((in DestroyData destroy, in Translation translation, in ColorData color) =>
        {
            if (destroy.Value == true)
            {
                var SD = new SpawnData();
                SD.numPrefabToSpawn = 7;
                SD.moveData         = new MoveData {
                    startPosition = translation.Value, targetPosition = translation.Value, nonStop = 0
                };
                SD.color = color.Value;
                ETS.Add(SD);
                var SD2 = new SpawnData();
                SD2.numPrefabToSpawn = 6;
                SD2.moveData         = new MoveData {
                    startPosition = translation.Value, targetPosition = new float3(translation.Value.x - 30, translation.Value.y, 0), nonStop = 0
                };
                ETS.Add(SD2);
            }
        }).Schedule();
Ejemplo n.º 26
0
    //Read Spawn File
    private void ReadSpawnFile()
    {
        spawnList = new List <SpawnData>();

        //1. Spawn List Clear
        spawnList.Clear();
        spawnIndex = 0;
        spawnEnd   = false;

        //2. Read Respawn File
        TextAsset    textFile     = Resources.Load("Stage " + currentLevel.ToString()) as TextAsset;
        StringReader stringReader = new StringReader(textFile.text);

        //3. Add Spawn Data
        while (stringReader != null)
        {
            string line = stringReader.ReadLine();
            if (line == null)
            {
                break;
            }

            SpawnData spawnData = new SpawnData();

            spawnData.delay = float.Parse(line.Split(',')[0]);
            spawnData.name  = line.Split(',')[1];
            spawnData.point = int.Parse(line.Split(',')[2]);
            spawnData.xDir  = float.Parse(line.Split(',')[3]);
            spawnData.yDir  = float.Parse(line.Split(',')[4]);
            spawnList.Add(spawnData);
        }

        nextSpawnTime = spawnList[0].delay;
        stringReader.Close();
    }
Ejemplo n.º 27
0
        public override void initialize(SpawnData spawnPoint)
        {
            int xDisplacement = 0;
            int yDisplacement = 0;

            switch (spawnPoint.orientation)
            {
            case OrientationType.up:
                yDisplacement = 5;
                break;

            case OrientationType.down:
                yDisplacement = -5;
                break;

            case OrientationType.left:
                xDisplacement = 5;
                break;

            case OrientationType.right:
                xDisplacement = -5;
                break;
            }

            Vector2 displacement = new Vector2(xDisplacement, yDisplacement);

            vector = spawnPoint.coordinate + displacement;

            base.initialize(spawnPoint);
        }
Ejemplo n.º 28
0
    public void DrawCircle()
    {
        if (selectedPrefab == null)
        {
            return;
        }
        List <SpawnData> newList = new List <SpawnData>();

        foreach (SpawnData data in Inspecting.spawns)
        {
            newList.Add(data);
        }
        undoStack.Push(newList);
        for (int i = 0; i < bCount; i++)
        {
            float      degree   = 360 * ((float)i / (float)bCount) * Mathf.Deg2Rad;
            Vector2    pos      = new Vector2(radius * Mathf.Cos(degree), radius * Mathf.Sin(degree));
            GameObject bullet   = Instantiate(selectedPrefab, pos, Quaternion.identity);
            SpawnData  newSpawn = new SpawnData();
            newSpawn.name     = selectedPrefab.name;
            newSpawn.position = pos;
            dict.Add(bullet, newSpawn);
            Inspecting.spawns.Add(newSpawn);
            list.Add(bullet);
        }
        EditorUtility.SetDirty(Inspecting);
    }
Ejemplo n.º 29
0
 void Start()
 {
     obstacleSpawner = GetComponent <ObstacleSpawner>();
     spawnData       = GetComponent <SpawnData>();
     // player = GetComponent<GameObject>();
     SetupNextStage();
 }
Ejemplo n.º 30
0
    public void DrawPolygon()
    {
        if (selectedPrefab == null)
        {
            return;
        }
        List <SpawnData> newList = new List <SpawnData>();

        foreach (SpawnData data in Inspecting.spawns)
        {
            newList.Add(data);
        }
        undoStack.Push(newList);
        Vector2 a = new Vector2(radius, 0), b;

        for (int i = 1; i <= eCount; i++)
        {
            float degree = 360 * ((float)i / (float)eCount) * Mathf.Deg2Rad;
            b = new Vector2(radius * Mathf.Cos(degree), radius * Mathf.Sin(degree));
            for (int j = 0; j < bCount; j++)
            {
                float      lerpValue = (float)j / (float)(bCount);
                Vector2    pos       = Vector2.Lerp(a, b, lerpValue);
                GameObject bullet    = Instantiate(selectedPrefab, pos, Quaternion.identity);
                SpawnData  newSpawn  = new SpawnData();
                newSpawn.name     = selectedPrefab.name;
                newSpawn.position = pos;
                dict.Add(bullet, newSpawn);
                Inspecting.spawns.Add(newSpawn);
                list.Add(bullet);
            }
            a = b;
        }
        EditorUtility.SetDirty(Inspecting);
    }
Ejemplo n.º 31
0
    // Update is called once per frame
    void Update()
    {
        while (curSpawn != null)
        {
            // currently negative z direction
            if (target.transform.position.z <= curSpawn.distance)
            {
                spawnEnemey(curSpawn);
                curSpawnId++;

                if (curSpawnId < curLevel.spawns.Count)
                {
                    curSpawn = curLevel.spawns[curSpawnId];
                }
                else
                {
                    // level ends
                    curSpawn = null;
                }
            }
            else
            {
                break;
            }
        }
    }
Ejemplo n.º 32
0
        public override void Pick(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, Vector3Int pivot)
        {
            if (brushTarget.layer == 31)
            {
                return;
            }
            //Tilemap layerTilemap = brushTarget.GetComponent<Tilemap>();
            UnitSpawner spawner = brushTarget.GetComponent <UnitSpawner>();
            Vector3Int  pos     = position.position;

            if (spawner == null)
            {
                Debug.LogError("TileMap对象必须包含一个 生怪器 组件");
                return;
            }
            if (m_window)
            {
                m_window.Close();
            }

            for (int i = 0; i < spawner.spawns.Count; i++)
            {
                if (pos == spawner.spawns[i].position)
                {
                    m_clipBoardBuff = spawner.spawns[i];
                    Debug.LogWarning("复制了刷怪器: @ " + position);
                    return;
                }
            }
        }
Ejemplo n.º 33
0
 public override CollectionBox GetBox(SpawnData other)
 {
     if (other == box.spawnData)
     {
         return(box);
     }
     return(null);
 }
Ejemplo n.º 34
0
 //Loads spawed objects, such as enemies and powerups
 public static List<PhysicalObject> loadSpawns(string spawnsPath)
 {
     byte[] fileData = File.ReadAllBytes(spawnsPath);
     List<PhysicalObject> spawnedObjects = new List<PhysicalObject>();
     for (int i = 0; i < fileData.Length; i += 3) //3 bytes per object
     {
         byte[] spawnByteData = SubArray(fileData, i, 3);
         SpawnData spawnData = new SpawnData(spawnByteData);
         spawnedObjects.Add(SpawnFactory.getSpawnFor(spawnData));
     }
     return spawnedObjects;
 }
Ejemplo n.º 35
0
    // 文字列から出現パターンデータを生成する.
    private SpawnData CreateSpawnData(string line)
    {
        string[] words = line.Split(); // 行内のワードを配列に格納.

        SpawnData spawnData = new SpawnData(); // パターンデータオブジェクトの作成.

        int n = 0;

        foreach(var word in words) {
            if(word == "") continue;		// ワードが空なら、1ワード読み飛ばす(ループの先頭に行く).

            switch(n) {
                case 0:
                    spawnData.name = word;
                    break;
                case 1:
                    spawnData.pos.x = float.Parse(word);
                    break;
                case 2:
                    spawnData.pos.y = float.Parse(word);
                    break;
                case 3:
                    spawnData.waitSec = float.Parse(word);
                    break;
                case 4:
                    spawnData.speed = float.Parse(word);
                    break;
            }
            n++;
        }

        if(n < 5) {	// 5項目(以上)が処理されていないならエラー.
            // データの個数が合っていないことを示すエラーメッセージを表示.
            Debug.LogError("[SpawnData] Out of parameter.\n");
            spawnData = null;
        }

        return spawnData;
    }
Ejemplo n.º 36
0
    void Awake()
    {
        int counter = 1;
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                mArray.Array[i][j] = counter++;
            }
        }
        mSpawnData = this.gameObject.GetComponent<SpawnData>();
        mSpawnState = SpawnState.Countdown;
        SpawnCounter = SpawnTime;
        AlienArray = new ArrayList();

        //for (int i = 0; i < 5; i++)
        //{
        //    CreateAlien(0, i, 1);
        //    CreateAlien(0, i, 2);
        //}
        //CreateAlien(0, 3, 4);
    }
Ejemplo n.º 37
0
 SpawnData[] EditSpawnDataArray(SpawnData[] spawnDataArray)
 {
     if(GUILayout.Button("Add SpawnData"))
     {
         spawnDataArray = Util.AddToArray<SpawnData>(new SpawnData(), spawnDataArray);
     }
     for(int i=0; i<spawnDataArray.Length; i++)
     {
         EditorGUILayout.LabelField("------------------------ SpawnData:" + spawnDataArray[i].Name);
         spawnDataArray[i].Name = EditorGUILayout.TextField("Name:",spawnDataArray[i].Name);
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.LabelField("Description:");
         spawnDataArray[i].Description = EditorGUILayout.TextArea(spawnDataArray[i].Description);
         EditorGUILayout.EndHorizontal();
         spawnDataArray[i].Spawned = (GameObject)EditorGUILayout.ObjectField("Spawned object:",spawnDataArray[i].Spawned, typeof(GameObject));
         spawnDataArray[i].objectDock = (ObjectDock)EditorGUILayout.ObjectField("Spawned Dock:",spawnDataArray[i].objectDock, typeof(ObjectDock));
         if(GUILayout.Button("Remove this SpawnData"))
         {
             spawnDataArray = Util.CloneExcept<SpawnData>(spawnDataArray, spawnDataArray[i]);
         }
         EditorGUILayout.Space();
     }
     return spawnDataArray;
 }
Ejemplo n.º 38
0
		// Update is called once per frame
	void SendEnemy()
	{
		//Debug.Log (enemyData.wait);

		if(m_index >= m_enemyList.Count)
		{
			return;
		}
		//第一次刷新敌人,初始化
		//Debug.Log (m_index);
		//Debug.Log (m_timer);
		if(m_index == 0 && m_timer == 0)
		{
			enemyData = (SpawnData)m_enemyList[m_index];
			//SpawnData data = (SpawnData)m_enemyList[m_index];
			m_timer = enemyData.wait;
			GameControl.instance.EnemyWave = enemyData.wave;

			//Debug.Log(enemyData.wait);

			//Debug.Log(enemyData.wait);
		}


		if(enemyData.wave > GameControl.instance.EnemyWave && GameControl.instance.EnemyLive > 0)
		{
			return;
			
		}
		else if(enemyData.wave > GameControl.instance.EnemyWave && GameControl.instance.EnemyLive == 0)
		{
			GameControl.instance.EnemyWave++;
		}

		//不满足延迟时间则返回

		Debug.Log (m_timer);
		m_timer = m_timer - Time.deltaTime ;
		//m_timer = m_timer - 0.02f;
		if(m_timer > 0)
		{
			return;
		}

		//满足延迟时间刷新下一个敌人

		eneName = enemyData.enemyName;

		enemyObj =  Instantiate(Resources.Load(eneName,typeof(GameObject))) as GameObject;
		string spawnName;
		spawnName = "EnemySpawner" + enemyData.level;
		Debug.Log (spawnName);
		GameObject obj = GameObject.Find(spawnName);


		//tep = Time.deltaTime;
		//m_timer = m_timer - (1.0f * Time.deltaTime);
		enemyObj.transform.position = obj.transform.position;
		//Instantiate(enemyObj, obj.transform.position, Quaternion.identity);
		GameControl.instance.EnemyLive++;
		m_index++;
		if(m_index >= m_enemyList.Count)
		{
			return;
		}
		enemyData = (SpawnData)m_enemyList[m_index];
		m_timer = enemyData.wait;






		//GameControl.instance.EnemyWave = enemyData.wave;
		//Debug.Log (m_timer);




		//int i;
		//i = Random.Range(1, 6);
		//Debug.Log(i.ToString());

		//Debug.Log (obj);
		
		//Instantiate(enemy, new Vector3(5f, 0.6f * i, 0f), Quaternion.identity);

		//Invoke("SendEnemy", 8);
		
	}
Ejemplo n.º 39
0
 /// <summary>
 /// Given a spawn data, and perform the actual spawning behavior.
 /// </summary>	
 GameObject Spawn(SpawnData spawnData)
 {
     GameObject spawned = (GameObject)Object.Instantiate (spawnData.Spawned);
     //assign the spawner field.
     if (spawned.GetComponent<Unit> () != null) {
         spawned.GetComponent<Unit> ().Spawner = this;
     }
     //locate the spawned object.
     spawnData.objectDock.Dock (spawned.transform);
     return spawned;
 }
Ejemplo n.º 40
0
    void TrySpawn(int x, int y)
    {
        if (WasKilled(x, y)) return;
        if (spawned.Any(s => s.x == x && s.y == y)) return;

        var h = Height(x, y);
        var type = GetSpawnType(h);
        if (type == null) return;
        var go = type.prefab.Duplicate(x+0.5f, 0, y+0.5f);
        var data = new SpawnData() {
            obj = go,
            x = x,
            y = y,
        };
        spawned.Add(data);
    }
Ejemplo n.º 41
0
 //TODO: Add enemy/powerup spawns using data
 public static PhysicalObject getSpawnFor(SpawnData data)
 {
     return null;
 }