Пример #1
0
    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;
        }
    }
Пример #2
0
 /**<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;
     }
 }
Пример #3
0
    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);
    }
Пример #4
0
    /**<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++;
    }
Пример #5
0
    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
    }
Пример #6
0
 private void Awake()
 {
     thisRef = this;
 }