Exemplo n.º 1
0
 public void JointRoom(CollisionBehaviour jointCb, DRoom jointRoom)
 {
     if (mJointsDict.ContainsKey(jointCb) == true)
     {
         mJointsDict[jointCb] = jointRoom;
     }
 }
Exemplo n.º 2
0
 void Start()
 {
     collBehaviour = GetComponent <CollisionBehaviour>();
     collider      = GetComponent <Collider2D>();
     camBounds     = Camera.main.GetComponent <CameraUtils>();
     target        = null;
 }
Exemplo n.º 3
0
 public void JointRoom(CollisionBehaviour jointCb, DRoom jointRoom)
 {
     if (mJointsDict.ContainsKey(jointCb) == true)
     {
         mJointsDict[jointCb] = jointRoom;
     }
 }
Exemplo n.º 4
0
    public DRoom GetJointRoom(CollisionBehaviour cb)
    {
        DRoom room = null;

        mJointsDict.TryGetValue(cb, out room);
        return(room);
    }
Exemplo n.º 5
0
        //----------------------------------------------------------------------------
        //----------------------------------------------------------------------------
        internal void ProcessFineCollisions(DeltaTime deltaTime)
        {
            if (m_collisionsFineList.Count > 0)
            {
                foreach (CollisionPair pair in m_collisionsFineList)
                {
                    if (pair.ColliderOne.Contains(pair.ColliderTwo))
                    {
                        MaterialCollisionItem item;
                        PhysicsBody           bodyOne   = pair.ColliderOne.Body;
                        PhysicsBody           bodyTwo   = pair.ColliderTwo.Body;
                        CollisionBehaviour    behaviour = CollisionBehaviour.DefaultCollision;

                        if (GetMaterialPair(pair.ColliderOne.Material, pair.ColliderTwo.Material, out item))
                        {
                            MatCollCallBack callBack = item.GetDelegate();

                            if (callBack != null)
                            {
                                behaviour = callBack(item.Pair, bodyOne, bodyTwo);
                            }
                        }

                        if (behaviour == CollisionBehaviour.DefaultCollision)
                        {
                            //do default collision here.
                        }
                    }
                }

                m_collisionsFineList.Clear();
            }
        }
Exemplo n.º 6
0
    IEnumerator nextRoomCoroutine(CollisionBehaviour cb)
    {
        SMovableObject mainRole = MainGameData.MainRole;

        mainRole.enabled = false;
        mainRole.SetKinematic(true);
        unregisterEvent();
        mCurRoom.OnExitRoom();
        //try get next room
        DRoom nextRoom = mCurRoom.GetJointRoom(cb);

        if (nextRoom == null)
        {
            //TODO: Be Random After
            GameObject go = Instantiate(Rooms[0]) as GameObject;
            nextRoom = go.GetComponent <DRoom>();
            nextRoom.Init();
            CollisionBehaviour nextCb = nextRoom.AlignmentOtherRoom(cb, mCurRoom.CenterPos);
            mCurRoom.JointRoom(cb, nextRoom);
            nextRoom.JointRoom(nextCb, mCurRoom);
        }
        StartCoroutine(mainRoleCutScene(nextRoom.CenterPos));
        yield return(StartCoroutine(SCameraMgr.Instance.moveToPos(nextRoom.CenterPos)));

        while (mRoleCurSceneEnable == true)
        {
            yield return(null);
        }
        mCurRoom = nextRoom;
        registerEvent();
        mCurRoom.OnEnterRoom();
        mainRole.SetKinematic(false);
        mainRole.enabled = true;
    }
Exemplo n.º 7
0
    void Start()
    {
        collBehaviour = GetComponent <CollisionBehaviour>();
        collider      = GetComponent <Collider2D>();
        camBounds     = Camera.main.GetComponent <CameraUtils>();
        float angleTorotate = Vector3.Angle(-transform.right, movementVector);

        transform.rotation *= Quaternion.Euler(0, 0, angleTorotate);
    }
Exemplo n.º 8
0
    void Start()
    {
        wmg = wire.GetComponent <CleanBezierCurve>();
        collisionBehaviour = this.gameObject.transform.GetChild(0).GetComponent <CollisionBehaviour>();
        animator           = this.gameObject.GetComponent <Animator>();

        startPos = new Vector3(0, 0.4f, -wire.GetComponent <CleanBezierCurve>().zOffsetPp) * wire.transform.localScale.y + wire.transform.position;
        wireStartPoint.transform.position = startPos;
        startPos.y += 0.035f;
        this.transform.position = startPos;
    }
Exemplo n.º 9
0
 public CollisionBehaviour AlignmentOtherRoom(CollisionBehaviour otherCb, Vector3 otherCenter)
 {
     int jointSize = mJointsDict.Count;
     CollisionBehaviour myAligCb = new List<CollisionBehaviour>(mJointsDict.Keys)[Random.Range(0, jointSize)];
     Vector3 tarDir = -(otherCb.transform.position - otherCenter);
     Vector3 curDir = myAligCb.transform.position - CenterPos;
     float sign = Vector3.Dot(Vector3.up, Vector3.Cross(tarDir,curDir)) < 0 ? 1 : -1;
     float angle = Vector3.Angle(tarDir,curDir);
     transform.Rotate(0, angle * sign, 0);
     CenterPos = CenterPos - myAligCb.transform.position + otherCb.transform.position;
     transform.position = CenterPos;
     return myAligCb;
 }
Exemplo n.º 10
0
 void Start()
 {
     extended          = false;
     collBehaviour     = GetComponent <CollisionBehaviour>();
     collider          = GetComponent <Collider2D>();
     camBounds         = Camera.main.GetComponent <CameraUtils>();
     line              = GetComponent <LineRenderer>();
     currentLineLength = 0;
     damageTimer       = 0;
     ShootingPos       = transform.position;
     line.SetPosition(0, ShootingPos);
     line.SetPosition(1, ShootingPos);
 }
Exemplo n.º 11
0
    public CollisionBehaviour AlignmentOtherRoom(CollisionBehaviour otherCb, Vector3 otherCenter)
    {
        int jointSize = mJointsDict.Count;
        CollisionBehaviour myAligCb = new List <CollisionBehaviour>(mJointsDict.Keys)[Random.Range(0, jointSize)];
        Vector3            tarDir   = -(otherCb.transform.position - otherCenter);
        Vector3            curDir   = myAligCb.transform.position - CenterPos;
        float sign  = Vector3.Dot(Vector3.up, Vector3.Cross(tarDir, curDir)) < 0 ? 1 : -1;
        float angle = Vector3.Angle(tarDir, curDir);

        transform.Rotate(0, angle * sign, 0);
        CenterPos          = CenterPos - myAligCb.transform.position + otherCb.transform.position;
        transform.position = CenterPos;
        return(myAligCb);
    }
Exemplo n.º 12
0
        /// <summary>
        /// Returns the block that the users mouse is hovering over.
        /// The rules are that
        /// </summary>
        /// <param name="collidingBlock">The position of the block that collided with the ChunkTracer.</param>
        /// <param name="behaviour">The behaviour that defines the rules of hit testing.</param>
        /// <returns>If the raytrace returned any blocks.</returns>
        public static bool TryHitTestBlock(CollisionBehaviour behaviour, [NotNull] ChunkTracer tracer, out BlockPosition collidingBlock)
        {
            switch (behaviour)
            {
            case CollisionBehaviour.Player:
                return(TryHitTestPlayer(tracer, out collidingBlock));

            case CollisionBehaviour.Editor:
                return(TryHitTestEditor(tracer, out collidingBlock));

            default:
                throw new ArgumentOutOfRangeException("behaviour");
            }
        }
Exemplo n.º 13
0
    public bool Init()
    {
        Transform jointRootTrans = transform.Find("Joints");

        if (jointRootTrans == null || jointRootTrans.childCount == 0)
        {
            Debug.LogError("!!!!!! This Room is no Joint !!!!!!");
            return(false);
        }

        int size = jointRootTrans.childCount;

        for (int i = 0; i < size; ++i)
        {
            Transform          childTrans = jointRootTrans.GetChild(i);
            CollisionBehaviour cb         = childTrans.gameObject.AddComponent <CollisionBehaviour>();
            mJointsDict.Add(cb, null);
        }
        return(true);
    }
Exemplo n.º 14
0
 public DRoom GetJointRoom(CollisionBehaviour cb)
 {
     DRoom room = null;
     mJointsDict.TryGetValue(cb, out room);
     return room;
 }
Exemplo n.º 15
0
 void Start()
 {
     collisionBehaviour = colliderParent.GetComponent <CollisionBehaviour>();
     wmg = wire.GetComponent <CleanBezierCurve>();
     cp  = ring.GetComponent <CheckPoint>();
 }
Exemplo n.º 16
0
 void nextRoomTriggerEnter(CollisionBehaviour cb)
 {
     StartCoroutine(nextRoomCoroutine(cb));
 }