Exemple #1
0
    public bool IsConjurable(EntityType type)
    {
        //Debug.Log("conjurable");
        GameObject prefab     = prefabDB.GetPrefab(type);
        Conjurable conjurable = prefab.GetComponent <Conjurable>();

        return(conjurable != null);
    }
Exemple #2
0
    public void Conjure(EvalContext context, EntityType type)
    {
        //Entity target = context.Target;

        GameObject prefab     = prefabDB.GetPrefab(type);
        Conjurable conjurable = prefab.GetComponent <Conjurable>();

        if (conjurable != null)
        {
            if (prefab.GetComponent <Entity>().occupySpace)
            {
                //Debug.Log("겹치는 거 소환");
                Collider[] hits = Physics.OverlapBox(context.Location, Vector3.one * 0.4f, Quaternion.identity, 2105);
                for (int i = 0; i < hits.Length; i++)
                {
                    //Debug.Log("체크");
                    Entity e = hits[i].GetComponent <Entity>();
                    if (e != null && e.occupySpace)
                    {
                        //Debug.Log("겹침");
                        return;
                    }
                }
            }

            //RuneStock.Inst.DeductRune(new RuneType(type));

            GameObject conjured       = Instantiate(prefab, context.Location, prefab.transform.rotation);
            Entity     conjuredEntity = conjured.GetComponent <Entity>();
            if (conjuredEntity == null)
            {
                Debug.LogError("Conjured entity does not have Entity component!");
                return;
            }
            context.Target = conjuredEntity;

            if (type == EntityType.Fire || type == EntityType.Electricity)
            {
            }
            else
            {
                conjured.transform.localScale = new Vector3(1, 1, 1) * 0.02f;
                //Rigidbody rb = conjured.GetComponent<Rigidbody>();
                Moveable moveable = conjured.GetComponent <Moveable>();
                if (moveable != null)
                {
                    moveable.Ungravitate();
                }

                StartCoroutine(
                    StartGradualAction(
                        timer =>
                {
                    conjured.transform.localScale = Vector3.Lerp(new Vector3(0, 0, 0), new Vector3(1, 1, 1), timer);
                    //Debug.Log(moveable);
                }, () =>
                {
                    conjured.transform.localScale = new Vector3(1, 1, 1);
                    if (moveable != null)
                    {
                        moveable.Gravitate();
                    }
                },
                        1.0f
                        )
                    );
            }
        }
        else
        {
            Debug.LogError($"Cannot conjure entity {type}");
        }
    }