Exemple #1
0
    private Indicator CreateIndicator(IndicatorType type)
    {
        Indicator indicator = Instantiate(type == IndicatorType.BOX ? boxIndicator : arrowIndicator);

        indicator.transform.SetParent(transform, false);
        indicator.Activate(false);
        return(indicator);
    }
Exemple #2
0
    void DrawIndicators()
    {
        GameObject[]  objects = GameObject.FindGameObjectsWithTag(targetTag); // Find all the objects with 'Target' tag in the scene.
        List <Target> targets = new List <Target>();

        objects.ToList().ForEach(obj =>
        {
            Target target = obj.GetComponent <Target>();
            if (target)
            {
                targets.Add(target);
            }
        });

        foreach (Target target in targets)
        {
            Vector3 screenPosition     = OffScreenIndicatorCore.GetScreenPosition(mainCamera, target.transform.position);
            bool    isTargetVisible    = OffScreenIndicatorCore.IsTargetVisible(screenPosition);
            float   distanceFromCamera = target.NeedDistanceText ? target.GetDistanceFromCamera(mainCamera.transform.position) : float.MinValue; // Gets the target distance from the camera.

            Indicator indicator = null;

            if (target.NeedBoxIndicator && isTargetVisible)
            {
                screenPosition.z = 0;
                indicator        = BoxObjectPool.current.GetPooledObject(); // Gets the box indicator from the pool.
            }
            else if (target.NeedArrowIndicator && !isTargetVisible)
            {
                float angle = float.MinValue;
                OffScreenIndicatorCore.GetArrowIndicatorPositionAndAngle(ref screenPosition, ref angle, screenCentre, screenBounds);
                indicator = ArrowObjectPool.current.GetPooledObject();                        // Gets the arrow indicator from the pool.
                indicator.transform.rotation = Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg); // Sets the rotation for the arrow indicator.
            }
            if (indicator)
            {
                indicator.SetImageColor(target.TargetColor);    // Sets the image color of the indicator.
                indicator.SetDistanceText(distanceFromCamera);  //Set the distance text for the indicator.
                indicator.transform.position = screenPosition;  //Sets the position of the indicator on the screen.
                indicator.SetTextRotation(Quaternion.identity); // Sets the rotation of the distance text of the indicator.
                indicator.Activate(true);                       // Sets the indicator as active.
            }

            //UI
            if (distanceFromCamera <= 100.0f)
            {
                timer.SetActive(true);
                if (makeUI == true)
                {
                    makeUI = false;

                    GameObject.Find("UIManager").SendMessage("getScore");

                    GameObject.Find("UIManager").SendMessage("gameEnd");
                }
            }
        }
    }
Exemple #3
0
 /// <summary>
 /// Get the indicator for the target.
 /// 1. If its not null and of the same required <paramref name="type"/>
 ///     then return the same indicator;
 /// 2. If its not null but is of different type from <paramref name="type"/>
 ///     then deactivate the old reference so that it returns to the pool
 ///     and request one of another type from pool.
 /// 3. If its null then request one from the pool of <paramref name="type"/>.
 /// </summary>
 /// <param name="indicator"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 private Indicator GetIndicator(ref Indicator indicator, IndicatorType type)
 {
     if (indicator != null)
     {
         if (indicator.Type != type)
         {
             indicator.Activate(false);
             indicator = type == IndicatorType.BOX ? BoxObjectPool.current.GetPooledObject() : ArrowObjectPool.current.GetPooledObject();
             indicator.Activate(true); // Sets the indicator as active.
         }
     }
     else
     {
         indicator = type == IndicatorType.BOX ? BoxObjectPool.current.GetPooledObject() : ArrowObjectPool.current.GetPooledObject();
         indicator.Activate(true); // Sets the indicator as active.
     }
     return(indicator);
 }
Exemple #4
0
    private void Start()
    {
        _pooledObjects = new List <Indicator>();

        for (int i = 0; i < pooledAmount; i++)
        {
            Indicator arrow = Instantiate(pooledObject, transform, false);
            arrow.Activate(false);
            _pooledObjects.Add(arrow);
        }
    }
    void Start()
    {
        pooledObjects = new List <Indicator>();

        for (int i = 0; i < pooledAmount; i++)
        {
            Indicator box = Instantiate(pooledObject);
            box.transform.SetParent(transform, false);
            box.Activate(false);
            pooledObjects.Add(box);
        }
    }
Exemple #6
0
    void Start()
    {
        pooledObjects = new List <Indicator>();

        for (int i = 0; i < pooledAmount; i++)
        {
            Indicator arrow = Instantiate(pooledObject);
            arrow.transform.SetParent(poolContainer, false);
            arrow.Activate(false);
            pooledObjects.Add(arrow);
        }
    }
Exemple #7
0
    void Start()
    {
        pooledObjects = new List <Indicator>();

        for (int i = 0; i < pooledAmount; i++)
        {
            Indicator arrow = Instantiate(pooledObject);
            arrow.DefaultRotation = arrow.transform.rotation;
            arrow.transform.SetParent(transform, false);
            arrow.Activate(false);
            pooledObjects.Add(arrow);
        }
    }
Exemple #8
0
    // Gets pooled objects from the pool.
    public Indicator GetPooledObject()
    {
        foreach (Indicator t in _pooledObjects.Where(t => !t.Active))
        {
            return(t);
        }

        if (!willGrow)
        {
            return(null);
        }

        Indicator arrow = Instantiate(pooledObject, transform, false);

        arrow.Activate(false);
        _pooledObjects.Add(arrow);
        return(arrow);
    }
Exemple #9
0
    private void DrawIndicators()
    {
        GameObject[]  objects = GameObject.FindGameObjectsWithTag("Target");
        GameObject    ethan   = GameObject.FindGameObjectWithTag("Ethan");
        List <Target> targets = new List <Target>();

        objects.ToList().ForEach(obj =>
        {
            Target target = obj.GetComponent <Target>();
            if (target && target.placed)
            {
                targets.Add(target);
            }
        });

        targets.Add(ethan.GetComponent <Target>());

        foreach (Target target in targets)
        {
            Vector3 camToObjectDirection = target.transform.position - mainCamera.transform.position;
            camToObjectDirection.Normalize();

            if (target.needArrowIndicator && !IsTargetVisible(target))
            {
                Indicator arrow = ArrowObjectPool.current.GetPooledObject();

                if (target.isEthan)
                {
                    arrow.transform.localScale = new Vector3(0.15f, 0.15f, 0.7f);
                }

                Quaternion defaultRotation = arrow.DefaultRotation;
                arrow.SetColor(target.targetColor);
                Vector3    position;
                Quaternion rotation;
                GetArrowIndicatorPositionAndRotation(camToObjectDirection, out position, out rotation);
                arrow.transform.position = position;
                arrow.transform.rotation = rotation * defaultRotation;

                arrow.Activate(true);
            }
        }
    }
 public Indicator GetPooledObject()
 {
     for (int i = 0; i < pooledObjects.Count; i++)
     {
         if (!pooledObjects[i].Active)
         {
             return(pooledObjects[i]);
         }
     }
     if (willGrow)
     {
         Indicator box = Instantiate(pooledObject);
         box.transform.SetParent(transform, false);
         box.Activate(false);
         pooledObjects.Add(box);
         return(box);
     }
     return(null);
 }
Exemple #11
0
    /// <summary>
    /// Draw the indicators on the screen and set thier position and rotation and other properties.
    /// </summary>
    void DrawIndicators()
    {
        foreach (Target target in targets)
        {
            Vector3   screenPosition     = OffScreenIndicatorCore.GetScreenPosition(mainCamera, target.transform.position);
            bool      isTargetVisible    = OffScreenIndicatorCore.IsTargetVisible(screenPosition);
            float     distanceFromCamera = target.NeedDistanceText ? target.GetDistanceFromCamera(mainCamera.transform.position) : float.MinValue;// Gets the target distance from the camera.
            Indicator indicator          = null;

            if (target.NeedBoxIndicator && isTargetVisible)
            {
                screenPosition.z = 0;
                indicator        = target.boxIndicator;
                target.arrowIndicator.Activate(false);
                indicator.SetImage(target.boxImage);
                indicator.SetText(target.boxText);
            }
            else if (target.NeedArrowIndicator && !isTargetVisible)
            {
                float angle = float.MinValue;
                OffScreenIndicatorCore.GetArrowIndicatorPositionAndAngle(ref screenPosition, ref angle, screenCentre, screenBounds);
                indicator = target.arrowIndicator;
                target.boxIndicator.Activate(false);
                indicator.transform.rotation = Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg); // Sets the rotation for the arrow indicator.
                indicator.SetImage(target.arrowImage);
                indicator.SetText(target.arrowText);
            }
            else
            {
                target.arrowIndicator.Activate(false);
                target.boxIndicator.Activate(false);
            }

            if (indicator != null)
            {
                indicator.SetImageColor(target.TargetColor);    // Sets the image color of the indicator.
                indicator.SetDistanceText(distanceFromCamera);  //Set the distance text for the indicator.
                indicator.transform.position = screenPosition;  //Sets the position of the indicator on the screen.
                indicator.SetTextRotation(Quaternion.identity); // Sets the rotation of the distance text of the indicator.
                indicator.Activate(true, target.gameObject);
            }
        }
    }
Exemple #12
0
 /// <summary>
 /// Gets pooled objects from the pool.
 /// </summary>
 /// <returns></returns>
 public Indicator GetPooledObject()
 {
     for (int i = 0; i < pooledObjects.Count; i++)
     {
         if (!pooledObjects[i].Active)
         {
             return(pooledObjects[i]);
         }
     }
     if (willGrow)
     {
         Indicator arrow = Instantiate(pooledObject);
         arrow.transform.SetParent(poolContainer, false);
         arrow.Activate(false);
         pooledObjects.Add(arrow);
         return(arrow);
     }
     return(null);
 }
 public void MakeColAble(Indicator ind, int b)
 {
     ind.Activate (b == 1);
 }
 // -----
 public void RechargeAmmo()
 {
     RechargeAmmoIndicator.Activate();
 }
    /*public void ShowInfo(E_MessageType message, float speed)
     * {
     *      Messages[message].Show(speed);
     *
     *      List<Message> sorted = new List<Message>();
     *
     *      foreach(KeyValuePair<E_MessageType, Message> m in Messages)
     *      {
     *              if(m.Value.IsVisible)
     *                      sorted.Add(m.Value);
     *      }
     *
     *      sorted.Sort((p1, p2) => p1.Progress.CompareTo(p2.Progress));
     *
     *      int layer = 1;
     *      foreach(KeyValuePair<E_MessageType, Message> m in Messages)
     *      {
     *              m.Value.SetLayer(layer++);
     *      }
     * }
     *
     * public void ShowAchievement(string text)
     * {
     *       AchievementInfo.Show(text);
     * }
     *
     * public void ShowHit()
     * {
     *      HitInfo.AddHit();
     * }
     * /**/

    // -----
    public void Heal()
    {
        HealIndicator.Activate();
    }