Ejemplo n.º 1
0
    void Start()
    {
        if (type == DemonType.Type.Null)
        {
            type = DemonType.Type.Dresh;
        }

        if (type == DemonType.Type.Kirgan)
        {
            demon = new DemonType.Kirgan();
        }
        else
        {
            demon = new DemonType.Dresh();
        }
        demon.Init(this);
        wanderTick = Random.Range(0, wanderTickMax);

        trail = gameObject.AddComponent <TrailComponent>();
        if (type == DemonType.Type.Dresh)
        {
            trail.Init(transform.Find("Sprite").GetComponent <SpriteRenderer>().sprite, 0.3f, 10, 0.8f);
            MonsterManager.dreshes.Add(gameObject);
        }
        else if (type == DemonType.Type.Kirgan)
        {
            trail.Init(transform.Find("Sprite").GetComponent <SpriteRenderer>().sprite, 0.5f, 5, 1f);
        }

        origPos = transform.position;
    }
Ejemplo n.º 2
0
        public void UpdateTrail(bool p_isPressing)
        {
            if (p_isPressing && Input.GetMouseButton(0))
            {
                _grabbing = true;
                if (CameraThatDrawThisObject != null && TrailComponent != null)
                {
                    if (Cutting)
                    {
                        _oldPosition = this.transform.position;
                    }
                    Vector3 v_position = CameraThatDrawThisObject.ScreenToWorldPoint(Input.mousePosition); //get position, where mouse cursor is
                    v_position.z = this.transform.position.z;

                    //position cutter object to touch/click position
                    TrailComponent.transform.position = v_position;

                    //Prevent Initial Bug When Showing the Trail
                    if (_currentDeltaTime > 0)
                    {
                        _currentDeltaTime = Mathf.Max(_currentDeltaTime - GetDeltaTime(), 0);
                    }

                    float v_distance = Vector2.Distance(_oldPosition, this.transform.position);
                    if (v_distance > MinDistanceToCut)
                    {
                        if (!Cutting && _currentDeltaTime <= 0)
                        {
                            TrailComponent.time = _trailTime;
                            TrailComponent.Clear();
                            Cutting      = true;
                            _oldPosition = v_position;
                        }
                    }
                    else
                    {
                        Cutting = false;
                    }
                }
            }
            else
            {
                ResetToNonPressingState();
            }
        }
 public void AddComponent(TrailComponent toAdd)
 {
     toAdd.Start();
     trails.AddLast(toAdd);
 }