예제 #1
0
 void UpdateClsns(ActionFrame frame)
 {
     if (rootClsns.childCount != 0)
     {
         List <GameObject> toDestroyList = new List <GameObject>();
         for (int i = 0; i < rootClsns.childCount; i++)
         {
             var child = rootClsns.GetChild(i);
             //GameObject.Destroy(child.gameObject);
             toDestroyList.Add(child.gameObject);
         }
         foreach (var go in toDestroyList)
         {
             GameObject.Destroy(go);
         }
         toDestroyList.Clear();
     }
     foreach (var clsn in frame.clsns)
     {
         var go = GameObject.Instantiate(prefabClsn, rootClsns);
         go.SetActive(true);
         WidgetCLSN wClsn = go.GetComponent <WidgetCLSN>();
         wClsn.toggle.onValueChanged.AddListener((v) => {
             if (v)
             {
                 this.curSelectedClsn = clsn;
             }
         });
         wClsn.Init(clsn);
     }
 }
예제 #2
0
 public void DeleteClsn(Clsn clsn)
 {
     if (actions != null && actions.Count != 0 && actions[curActionIndex].frames != null && actions[curActionIndex].frames.Count != 0)
     {
         actions[curActionIndex].frames[curActionElemIndex].clsns.Remove(clsn);
     }
 }
예제 #3
0
    public Clsn CreateClsnBox(InputPlayerType playerType, string name, Transform parent, float x, float y, float w, float h, bool isClsn2 = true)
    {
        Clsn r = GetClsnColliderFromPool(name);

        if (r == null)
        {
            return(r);
        }

        var trans = r.transform;

        if (trans.parent != parent)
        {
            trans.SetParent(parent, false);
        }

        ClsnType tt = isClsn2 ? ClsnType.def: ClsnType.attack;

        r.Init(playerType, tt, x, y, w, h);

        if (!r.gameObject.activeSelf)
        {
            r.gameObject.SetActive(true);
        }

        return(r);
    }
예제 #4
0
    private void OnClsnCollision(Clsn other)
    {
        if (other == null || !m_IsVisible)
        {
            return;
        }
        if ((PlayerType == other.PlayerType) || (type == other.type))
        {
            return;
        }
        if (type == ClsnType.attack)
        {
            PlayerDisplay owner  = PlayerControls.GetInstance().GetPlayer(PlayerType);
            PlayerDisplay target = PlayerControls.GetInstance().GetPlayer(other.PlayerType);

            if (owner != target && owner != null && target != null)
            {
                // 能否被攻击
                if (target.OnAttacked(owner))
                {
                    owner.OnAttack(target);
                }
            }
        }
    }
예제 #5
0
        public void Init(Clsn clsn)
        {
            this.m_clsn = clsn;
            if (clsn.type == 1)
            {
                this.img.color = Color.blue;
            }
            else if (clsn.type == 2)
            {
                this.img.color = Color.red;
            }
            else if (clsn.type == 3)
            {
                this.img.color = Color.black;
            }
            //var leftDown = new Vector3(this.m_clsn.x1, this.m_clsn.y1, 0);
            //var rightUp = new Vector3(this.m_clsn.x2, this.m_clsn.y2, 0);
            //this.leftDown.GetComponent<RectTransform>().position = ActionsEditorController.Instance.ScenePosToUIPos(leftDown);
            // this.rightUp.GetComponent<RectTransform>().position = ActionsEditorController.Instance.ScenePosToUIPos(rightUp);
            this.leftDown.onDrag += (uipos) => {
                var leftDownPos = ActionsEditor.Instance.view.UIPosToScenePos(uipos);
                this.m_clsn.x1 = leftDownPos.x.ToNumber();
                this.m_clsn.y1 = leftDownPos.y.ToNumber();
            };

            this.rightUp.onDrag += (uipos) =>
            {
                var rightDownPos = ActionsEditor.Instance.view.UIPosToScenePos(uipos);
                this.m_clsn.x2 = rightDownPos.x.ToNumber();
                this.m_clsn.y2 = rightDownPos.y.ToNumber();
            };
            this.isInited = true;
        }
예제 #6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision != null)
     {
         Clsn other = collision.GetComponent <Clsn>();
         OnClsnCollision(other);
     }
 }
예제 #7
0
 public void UseLastClsns()
 {
     if (actions != null && actions.Count != 0 && actions[curActionIndex].frames != null && actions[curActionIndex].frames.Count >= 2 && curActionElemIndex >= 1)
     {
         actions[curActionIndex].frames[curActionElemIndex].clsns = new List <Clsn>();
         var lastElem = actions[curActionIndex].frames[curActionElemIndex - 1];
         foreach (var clsn in lastElem.clsns)
         {
             Clsn newClsn = new Clsn(clsn);
             actions[curActionIndex].frames[curActionElemIndex].clsns.Add(newClsn);
         }
     }
 }
예제 #8
0
 public void CreateClsn(int type)
 {
     if (actions != null && actions.Count != 0 && actions[curActionIndex].frames != null && actions[curActionIndex].frames.Count != 0)
     {
         Clsn clsn = new Clsn();
         clsn.type = type;
         clsn.x1   = -1;
         clsn.y1   = -1;
         clsn.x2   = 1;
         clsn.y2   = 1;
         actions[curActionIndex].frames[curActionElemIndex].clsns.Add(clsn);
     }
 }
예제 #9
0
    public void DestroyBoxCollider(Clsn box)
    {
        if (box == null)
        {
            return;
        }
        if (box.transform.parent == m_ClsnColliderPoolRoot.transform)
        {
            return;
        }

        box.transform.SetParent(m_ClsnColliderPoolRoot.transform, false);
    }
예제 #10
0
    protected Clsn GetClsnColliderFromPool(string name)
    {
        if (m_ClsnColliderPoolRoot == null)
        {
            return(null);
        }
        var trans = m_ClsnColliderPoolRoot.transform;

        if (trans.childCount > 0)
        {
            var child = trans.GetChild(trans.childCount - 1);
            child.gameObject.SetActive(false);
            child.SetParent(null, false);
            child.name = name;
            Clsn ret = child.GetComponent <Clsn>();
            return(ret);
        }
        GameObject gameObj = new GameObject(name, typeof(Clsn));
        Clsn       r       = gameObj.GetComponent <Clsn>();

        return(r);
    }