void TouchDown(Vector2 touch) { if (!inGameplay) { return; } activeSpawner = null; Vector2 point = Camera.main.ScreenToWorldPoint(touch); if (point.y < -1f) { var minDistance = 100000.0f; RaycastSpawner shooter = null; //look for closest shooter foreach (var s in spawners) { var d = Vector2.Distance(point, s.transform.position); if (d < minDistance) { minDistance = d; shooter = s; } } activeSpawner = shooter; } }
/**<summary> Set random navmesh point in current area as target </summary>*/ virtual public void RandomTarget() { if (agent.isOnNavMesh) { target = RaycastSpawner.GetRandomPoint(WorldController.CurrentAreaBounds()); agent.destination = target; } }
private RaycastSpawner GetAvailableSpawners() { // Send an event and get all of the available spawners based on the listening spawners // if none are available, then return nothing // btw we should return a gameobject or something RaycastSpawner raycastSpawner = null; return(raycastSpawner); }
/**<summary> Add Collectable to the world </summary>*/ public void AddCollectable() { ItemData item = Instantiate(energyTemplates[UnityEngine.Random.Range(0, energyTemplates.Length)]); item.position = RaycastSpawner.GetRandomPoint(currentArea.bounds.GetUnityBounds(), player.position, 3, energyMaxDistance); #pragma warning disable 4014 AddItem(item, false); #pragma warning restore 4014 lastCollectableTime = Time.time + UnityEngine.Random.Range(-energySpawnRate * 0.1f, energySpawnRate * 0.1f); energyAmount++; }
private void Start() { thisRef = this; player = FindObjectOfType <Player>().transform; raycastSpawner = FindObjectOfType <RaycastSpawner>(); ServerAPI.OnGetItemsResponse += OnGetItemsResponse; ServerAPI.OnSetItemsResponse += OnSetItemsResponse; ServerAPI.OnDeleteItemsResponse += OnDeleteItemsResponse; //SetupWorld(new Area()); #if UNITY_EDITOR #endif }
private void Awake() { thisRef = this; }