/// <summary> /// Instantiate all targets in the game world using their respective prefabs. /// </summary> protected void Spawn() { foreach (var target in Targets) { Transform prefab; switch (TargetType) { case TargetType.Paper: throw new NotImplementedException(); case TargetType.Dummy: prefab = DummyTargetPrefab; break; case TargetType.Person: prefab = GetRandomNpc(); break; default: throw new ArgumentOutOfRangeException(); } target.Spawn(prefab); if (target is TargetNpc) { TargetNpc tnpc = ((TargetNpc)target); tnpc.NPC.IsPanicking = false; tnpc.NPC.OnNPCDeathEvent += OnNpcDeath; tnpc.NPC.OnNPCHitEvent += OnNpcHit; } } }
private Target NewTarget() { Target t = new TargetNpc(); t.IsHostile = true; t.ItemType = ItemType.P99; t.Position = new Vector3(5, 1, 5); Waypoint waypoint = new GameObject().AddComponent <Waypoint>(); waypoint.Owner = t; waypoint.Position = new Vector3(10, 1, 10); t.Waypoints.Add(waypoint); return(t); }
/// <summary> /// Spawn an npc /// </summary> /// <param name="hostile">wether the npc is hostile</param> /// <param name="type">what kind of npc is to be spawned</param> /// <param name="location">location of the npc</param> /// <param name="rotation">rotation of the npc</param> private void SpawnNPC(bool hostile, Transform type, Vector3 location, Quaternion rotation) { // Create npc TargetNpc t = new TargetNpc(); t.Difficulty = difficulty; t.ItemType = ItemType.P99; t.Position = location; t.IsHostile = hostile; Targets.Add(t); // Spawn npc Transform trans = t.Spawn(type); t.NPC.OnNPCDeathEvent += OnNPCDeath; trans.rotation = rotation; }
/// <summary> /// loads the targettype of the target /// </summary> private Target LoadTarget() { Target target; switch (_scenario.TargetType) { case TargetType.Paper: throw new NotImplementedException("I don't know how to make paper targets!"); case TargetType.Dummy: throw new NotImplementedException("I don't know how to make dummy targets!"); case TargetType.Person: target = new TargetNpc(); break; default: throw new ArgumentOutOfRangeException(); } return(target); }
/// <summary> /// Get the correct targetType /// </summary> private static Target GetTarget() { Target target; switch (ScenarioBase.Instance.TargetType) { case TargetType.Paper: throw new NotImplementedException("I don't know how to make paper targets!"); case TargetType.Dummy: target = new TargetNpc(); break; case TargetType.Person: target = new TargetNpc(); break; default: throw new ArgumentOutOfRangeException(); } return(target); }