Ejemplo n.º 1
0
 void Start()
 {
     config   = MagicConfig.Get(MagicId);
     lifeTime = config.Duration / 1000f;
     delay    = config.Delay / 1000f;
     period   = config.Period / 1000f;
 }
Ejemplo n.º 2
0
    new void Start()
    {
        base.Start();
        var card    = GetComponent <Property>().CardID;
        var _unitID = CardConfig.Get(card).Value;

        skillID = UnitConfig.Get(_unitID).Skill;
        skillCD = UnitConfig.Get(_unitID).SkillCD;
        magicC  = MagicConfig.Get(skillID);
    }
Ejemplo n.º 3
0
    void IDragHandler.OnDrag(PointerEventData eventData)
    {
        transform.position = Input.mousePosition;
        var        image = gameObject.GetComponent <Image>();
        var        ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, int.MaxValue, 1 << LayerMask.NameToLayer(CONSTANT.CONST.LAYER_GROUND)))
        {
            image.enabled = false;
            if (prefab)
            {
                prefab.SetActive(true);
                prefab.transform.position = hit.point;
            }
            else
            {
                var config = CardConfig.Get(cardID);
                switch ((ENUM_TYPE)config.Type)
                {
                case ENUM_TYPE.UNIT:
                    var path = UnitConfig.Get(config.Value).Resource;
                    prefab = Instantiate(Resources.Load(path), GameObject.Find(CONSTANT.CONST.PATH_AREA_A).transform) as GameObject;
                    foreach (var component in prefab.GetComponents <Component>())
                    {
                        if (!(component is Transform))
                        {
                            Destroy(component);
                        }
                    }
                    prefab.transform.position = hit.point;
                    prefab.transform.Rotate(new Vector3(0, 90, 0));
                    break;

                case ENUM_TYPE.MAGIC:
                    var path2 = MagicConfig.Get(config.Value).Resource;
                    prefab = Instantiate(Resources.Load(path2), GameObject.Find(CONSTANT.CONST.PATH_AREA_A).transform) as GameObject;
                    prefab.transform.position = hit.point;
                    break;

                default:
                    Debug.LogError("ENUM_TYPE can not find");
                    break;
                }
            }
        }
        else
        {
            image.enabled = true;
            if (prefab)
            {
                prefab.SetActive(false);
            }
        }
    }
Ejemplo n.º 4
0
    public void CreateMagic(int id, Vector3 position)
    {
        var path   = MagicConfig.Get(id).Resource;
        var parent = GameObject.Find(CONSTANT.CONST.PATH_BORN_C).transform;
        var obj    = Instantiate(Resources.Load(path), position, Quaternion.Euler(new Vector3(0, 90, 0)), parent) as GameObject;
        var ppt    = obj.GetComponent <Property>();

        ppt.CardID   = id;
        ppt.Side     = ENUM_SIDE.A;
        ppt.UnitType = ENUM_UNIT_TYPE.OTHER;
    }