コード例 #1
0
        protected bool IfTouching(BoxCollider2D collisn, object characterdata)
        {
            if (collisn == null)
            {
                return(false);
            }

            Collider2D chara = Physics2D.OverlapBox(collisn.transform.position, collisn.size, 0);

            if (chara == null)
            {
                return(false);
            }
            if (chara.gameObject == gameObject)
            {
                return(false);
            }

            //print(chara.gameObject.GetComponent<s_object>().GetType());
            s_object obj = chara.gameObject.GetComponent <s_object>();

            if (obj == null)
            {
                return(false);
            }

            if (obj.GetType() == characterdata)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        protected Collider2D IfTouchingGetCol <T>(BoxCollider2D collisn, string character) where T : s_object
        {
            if (collisn == null)
            {
                return(null);
            }

            Collider2D[] chara = Physics2D.OverlapBoxAll(collisn.transform.position, collisn.size, 0);

            if (chara == null)
            {
                return(null);
            }
            for (int i = 0; i < chara.Length; i++)
            {
                Collider2D co = chara[i];
                if (co.gameObject == gameObject)
                {
                    continue;
                }

                //print(chara.gameObject.GetComponent<s_object>().GetType());
                s_object obj = chara[i].gameObject.GetComponent <T>();
                if (obj == null)
                {
                    continue;
                }
                if (obj.name == character)
                {
                    return(co);
                }
            }
            return(null);
        }
コード例 #3
0
        public new void Update()
        {
            base.Update();
            if (!s_triggerhandler.trig.doingEvents)
            {
                switch (TRIGGER_T)
                {
                case TRIGGER_TYPE.CONTACT:

                    o_character c = IfTouchingGetCol <o_character>(collision);
                    if (c != null)
                    {
                        selobj = c.gameObject.GetComponent <s_object>();
                        //print(name + c.name);
                        if (selobj)
                        {
                            o_character posses = selobj.GetComponent <o_character>();
                            //print(name + c.name);
                            o_character ch = c.GetComponent <o_character>();
                            if (ch)
                            {
                                if (!ch.AI)
                                {
                                    //print("Activating trigger");
                                    s_triggerhandler.trig.selobj = selobj;
                                    if (stringLabelToJumpTo != "")
                                    {
                                        s_triggerhandler.trig.JumpToEvent(stringLabelToJumpTo, callstatic);
                                    }
                                    else
                                    {
                                        s_triggerhandler.trig.JumpToEvent(LabelToJumpTo, callstatic);
                                    }
                                    if (destroyOnTouch)
                                    {
                                        Destroy(gameObject);
                                    }
                                }
                            }
                        }
                    }
                    break;

                case TRIGGER_TYPE.CONTACT_INPUT:
                    if (Input.GetKeyDown(s_globals.GetKeyPref("select")))
                    {
                        c = IfTouchingGetCol <o_character>(collision);
                        if (c != null)
                        {
                            selobj = c.gameObject.GetComponent <s_object>();
                            //print(name + c.name);
                            if (selobj)
                            {
                                o_character posses = selobj.GetComponent <o_character>();
                                o_character ch     = posses.GetComponent <o_character>();
                                if (ch)
                                {
                                    if (!ch.AI)
                                    {
                                        //print("Activating trigger");
                                        s_triggerhandler.trig.selobj = selobj;
                                        if (stringLabelToJumpTo != "")
                                        {
                                            s_triggerhandler.trig.JumpToEvent(stringLabelToJumpTo, callstatic);
                                        }
                                        else
                                        {
                                            s_triggerhandler.trig.JumpToEvent(LabelToJumpTo, callstatic);
                                        }
                                        if (destroyOnTouch)
                                        {
                                            Destroy(gameObject);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }
コード例 #4
0
 public void SetTransformPar(s_object o)
 {
     parentTrans = o;
 }