Example #1
0
    IEnumerator LongClick(Vector2 target)
    {
        yield return(new WaitForSeconds(1f));

        if ((target - longClickPos).magnitude < Screen.width / 10)
        {
            Vector3    mousepos = Camera.main.ScreenToWorldPoint(target) + Vector3.one * 0.5f;
            Vector2Int tileIdx  = new Vector2Int((int)mousepos.x, (int)mousepos.y);
            if (FieldManager.IsInField(tileIdx))
            {
                InfoView.instance.infoPanel.SetActive(true);
                Tile tile = FieldManager.GetTile(tileIdx);
                InfoView.Show(tile);

                Unit unit = tile.GetUnit();
                if (unit != null)
                {
                    InfoView.Show(unit);
                }

                Obtainable obtainable = tile.GetObtainable();
                if (obtainable != null)
                {
                    InfoView.Show(obtainable);
                }
            }
        }
    }
Example #2
0
        public static void DestroyObtainableObject(Obtainable ob)
        {
            GameObject obObj = ObtainableObjects[ob];

            ObtainableObjects.Remove(ob);
            Destroy(obObj);
        }
Example #3
0
        public static void MakeDropEffect(Vector3 startPos, Vector3 target, Obtainable obtainable)
        {
            GameObject obj = BattleView.ObtainableObjects[obtainable];

            obj.transform.position = startPos;

            GameObject trailRenderObj = Instantiate(Resources.Load <GameObject>("TrailRenderObj"), obj.transform);

            trailRenderObj.transform.localPosition = Vector3.zero;
            IEnumerator Coroutine()
            {
                float duration = 0.3f;
                float t        = 0;

                Vector3 straightPosition = startPos;

                //Vector2 direction = new Vector2(target.x - startPos.x, target.y - startPos.y).normalized;
                //Vector2 curvedDiretion = new Vector2(direction.y, -direction.x);
                while (t < duration)
                {
                    t += Time.deltaTime;
                    straightPosition = Vector3.Lerp(startPos, target, t / duration);

                    obj.transform.position = straightPosition; //+ (Vector3)curvedDiretion * Mathf.Sin(Mathf.PI * t / duration);
                    //obj.transform.localScale = Vector3.one * (1 - Mathf.Sin(Mathf.PI * t / duration));
                    yield return(null);
                }
                obj.transform.position = target;
                Destroy(trailRenderObj);
            }

            instance.StartCoroutine(Coroutine());
        }
Example #4
0
    //Target Finding
    public void OnTriggerStay(Collider other)
    {
        if (other.transform.parent.transform == PlayerManager.instance.player.transform)
        {
            Vector3 direction = other.transform.position - transform.position;
            float   angle     = Vector3.Angle(direction, transform.forward);

            if (angle < fieldOfViewAngle * 0.5f)
            {
                RaycastHit hitInfo;
                if (Physics.Raycast(transform.position + transform.up, direction.normalized, out hitInfo, curLookRadius))
                {
                    if (hitInfo.collider.gameObject.transform.parent.transform == PlayerManager.instance.player.gameObject.transform)
                    {
                        target = PlayerManager.instance.player.transform;
                        FaceTarget();
                    }
                }
            }
        }
        else
        {
            Obtainable obj = other.transform.GetComponentInParent <Obtainable>();

            if (obj != null)
            {
                if (other.transform.parent.gameObject.layer == PlayerManager.instance.player.gameObject.layer)
                {
                    Vector3 direction = other.transform.position - transform.position;
                    float   angle     = Vector3.Angle(direction, transform.forward);

                    if (angle < fieldOfViewAngle * 0.5f)
                    {
                        RaycastHit hitInfo;

                        if (Physics.Raycast(transform.position, direction.normalized, out hitInfo, curLookRadius))
                        {
                            Debug.Log(hitInfo.collider.transform.parent.name);

                            if (hitInfo.collider.transform.parent == obj.transform)
                            {
                                if (!obj.isBeingHeld())
                                {
                                    target = other.transform;
                                    FaceTarget();
                                }
                                else
                                {
                                    target = null;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Example #5
0
    public void Activate()
    {
        RaycastHit hitInfo;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hitInfo, InteractionRange, PropLayer))
        {
            //Name of the items


            //Item checks
            Obtainable    heldItem = cam.transform.GetComponentInChildren <Obtainable>();
            Obtainable    Obj      = hitInfo.transform.GetComponentInParent <Obtainable>();
            Unlockable    _lock    = hitInfo.transform.GetComponentInParent <Unlockable>();
            Rotating_Door Door     = hitInfo.transform.GetComponentInParent <Rotating_Door>();

            //Instance Checks and Logic
            if (Door != null)
            {
                if (_lock != null)
                {
                    foreach (Transform item in inventory)
                    {
                        _lock.Deactivate(item);
                    }
                    Door.Activate();
                }
                else
                {
                    Door.Activate();
                }
            }

            if (Obj != null)
            {
                if (Obj.CompareTag("Collectable"))
                {
                    inventory.Add(Obj.transform);
                    Obj.Destroy();
                    Debug.Log(inventory);
                }
            }


            if (heldItem == null)
            {
                if (Obj != null)
                {
                    Obj.Activate(cam);
                }
            }
            else
            {
                heldItem.Deactivate();
            }
        }
    }
Example #6
0
 public static void UnSummon(this Obtainable obtainable)
 {
     if (obtainable.Position == null)
     {
         return;
     }
     FieldManager.GetTile((Vector2Int)obtainable.Position).SetObtainable(null);
     BattleView.DestroyObtainableObject(obtainable);
     BattleManager.instance.AllObtainables.Remove(obtainable);
 }
Example #7
0
    public void Throw(float power)
    {
        //Item checks
        Obtainable heldItem = cam.transform.GetComponentInChildren <Obtainable>();

        if (heldItem != null)
        {
            heldItem.Throw(cam, power);
        }
    }
Example #8
0
 // Update is called once per frame
 void Update()
 {
     if (_colliderItem != null)
     {
         if (Input.GetButtonDown("Interact"))
         {
             Obtainable item = _colliderItem.GetComponent <Item>().ItemType;
             _controller.EquipItem(item);
             Destroy(_colliderItem.gameObject);
             _colliderItem = null;
         }
     }
 }
Example #9
0
        public static void UnSummon(Vector2Int position)
        {
            Tile       tile = FieldManager.GetTile(position);
            Obtainable obt  = tile.GetObtainable();
            Unit       unit = tile.GetUnit();

            if (obt != null)
            {
                UnSummon(obt);
            }
            if (unit != null)
            {
                UnSummon(unit);
            }
        }
Example #10
0
    public void OnTriggerEnter(Collider other)
    {
        Obtainable obj = other.transform.GetComponentInParent <Obtainable>();

        //&& other.transform.gameObject.layer == PlayerManager.instance.player.transform.gameObject.layer


        if (obj != null && !obj.isBeingHeld())
        {
            Debug.Log("Ive Been Hit");
            float _damage = obj.GetPower() * .1f;
            TakeDamage(_damage);
            Invoke("TurnOffAnim", animTime);
        }
    }
Example #11
0
 // 최초 Obatainable 최초 소환
 public static void Summon(this Obtainable obtainable, Vector2Int position)
 {
     if (BattleManager.GetUnit(position) != null)
     {
         AddObtainable(BattleManager.GetUnit(position), obtainable);
     }
     else if (BattleManager.GetObtainable(position) == null)
     {
         FieldManager.GetTile(position).SetObtainable(obtainable);
         obtainable.Position = position;
         BattleManager.instance.AllObtainables.Add(obtainable);
         BattleView.MakeObtainableObject(obtainable, position);
         // Debug.Log(obtainable.ToString());
     }
     else
     {
         Debug.LogWarning("이미 위치에 뭔가 존재합니다.");
     }
 }
Example #12
0
 /// <summary>
 /// 땅에 있는걸 줍는다.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="obtainable"></param>
 public static void AddObtainable(this Unit target, Obtainable obtainable)
 {
     if (obtainable.ToString().Contains("Artifacts"))
     {
         AddArtifact(target, (Artifact)obtainable);
         UnSummon(obtainable);
     }
     else if (obtainable.ToString().Contains("Items"))
     {
         if (target.Alliance == UnitAlliance.Party && GameManager.Instance.itemBag.Count == 3)
         {
             return;
         }
         else
         {
             AddItem((Item)obtainable);
             UnSummon(obtainable);
         }
     }
 }
Example #13
0
    public void EquipItem(Obtainable item)
    {
        if (_isReloading)
        {
            return;
        }

        Type itemType = item.GetType();

        if (itemType == typeof(Weapon))
        {
            EquipWeapon(item.name);
        }
        else if (itemType == typeof(HealingItem))
        {
            EquipHealingItem(item.name);
        }
        else if (itemType == typeof(Grenade))
        {
            EquipGrenade(item.name);
        }
    }
Example #14
0
        public static void MakeObtainableObject(Obtainable ob, Vector2Int pos)
        {
            // 게임 오브젝트 생성
            GameObject obObj = new GameObject(ob.Name);

            // 위치 지정
            obObj.transform.position = new Vector3(pos.x, pos.y, 0.1f);

            // 스프라이터 랜더러 추가
            SpriteRenderer spriteRenderer = obObj.AddComponent <SpriteRenderer>();

            if (ob.GetType().BaseType == typeof(Artifact))
            {
                spriteRenderer.sprite = ob.Sprite;
            }
            else
            {
                spriteRenderer.sprite = ob.Sprite;
                // if (ob.Color != new Color(0,0,0,0))
                //     spriteRenderer.color = ob.Color;
            }

            ObtainableObjects.Add(ob, obObj);
        }
Example #15
0
 public static void Show(Obtainable obtainable)
 {
     instance.simpleInfo.Set(obtainable);
 }
Example #16
0
 public void RemoveObtainable(Obtainable obtainable)
 {
     m_Obtainables.Remove(obtainable);
 }
Example #17
0
 public bool ContainsObtainable(Obtainable obtainable)
 {
     return(m_Obtainables.Contains(obtainable));
 }
 public void AddObtainable(Obtainable obtainable)
 {
     m_Inventory.AddObtainable(obtainable);
     m_CommonUIBehaviour.EnqueueNotification($"Obtained {obtainable.name}");
 }
Example #19
0
 void Start()
 {
     rb = GetComponent <Rigidbody2D>();
     ob = FindObjectOfType <Obtainable>();
     fo = FindObjectOfType <FishObtain>();
 }
Example #20
0
 public void AddObtainable(Obtainable obtainable)
 {
     m_Obtainables.Add(obtainable);
 }