// Find the doors of the room

    public void findDoors(GameObject room)
    {
        MyRoom mr        = room.GetComponent <MyRoom>();
        MyDoor enterDoor = null;
        MyDoor exitDoor  = null;

        if (mr.enterDoor != null)
        {
            enterDoor = mr.enterDoor.GetComponent <MyDoor>();
        }

        if (mr.exitDoor != null)
        {
            exitDoor = mr.exitDoor.GetComponent <MyDoor>();
        }

        if ((enterDoor != null && enterDoor.side == 0) || (exitDoor != null && exitDoor.side == 0))
        {
            doorAtZero = true;
        }

        else
        {
            doorAtZero = false;
        }

        if ((enterDoor != null && enterDoor.side == 1) || (exitDoor != null && exitDoor.side == 1))
        {
            doorAtOne = true;
        }

        else
        {
            doorAtOne = false;
        }

        if ((enterDoor != null && enterDoor.side == 2) || (exitDoor != null && exitDoor.side == 2))
        {
            doorAtTwo = true;
        }

        else
        {
            doorAtTwo = false;
        }

        if ((enterDoor != null && enterDoor.side == 3) || (exitDoor != null && exitDoor.side == 3))
        {
            doorAtThree = true;
        }

        else
        {
            doorAtThree = false;
        }
    }
Example #2
0
        public void TestAutoDoorCloser()
        {
            gridTerminalSystem = MockRepository.GenerateStub <IMyGridTerminalSystem>();
            doorManager        = new Program.DoorManager(gridTerminalSystem);
            var terminalDoors = new List <IMyTerminalBlock>();
            var door          = new MyDoor();

            gridTerminalSystem.Stub(x => x.GetBlocksOfType <IMyTerminalBlock>(new List <IMyTerminalBlock>(), Program.DoorManager.IsAutoclosedDoor)).Do(
                new Action <object>(x => terminalDoors.Add(door)));

            Assert.AreEqual(1, doorManager.GetStoredDoorsCount);
        }
Example #3
0
        static void ChangeDoorSuccess(ref ChangeDoorMsg msg, MyNetworkClient sender)
        {
            MyEntity entity;

            MyEntities.TryGetEntityById(msg.EntityId, out entity);
            MyDoor block = entity as MyDoor;

            if (block != null)
            {
                block.Open = msg.Open;
            }
        }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        string tag = collision.gameObject.tag;

        if (tag == "Leave")
        {
            Destroy(collision.gameObject);
            GameObject.FindObjectOfType <AudioManager>().Play("Take Item");

            if (pm.leaves < 12)
            {
                pm.leaves += 1;
            }
        }

        if (tag == "Life")
        {
            if (pm.health < 6)
            {
                Destroy(collision.gameObject);
                pm.health += 1;
                GameObject.FindObjectOfType <AudioManager>().Play("Take Item");
            }
        }

        if (tag == "Door")
        {
            MyDoor md = collision.gameObject.GetComponent <MyDoor>();
            if (md.opened)
            {
                if (md.bossDoor)
                {
                    PlayerPrefs.SetInt("Lifes", pm.health);
                    PlayerPrefs.SetInt("Leaves", pm.leaves);
                    pm.sceneName = "BossFight";
                    StartCoroutine(pm.LoadScene());
                }

                else
                {
                    pm.changeRoom(md.side, md.roomTo);
                }
            }
            else
            {
                pm.FixDirection();
            }
        }
    }
 public MyUseObjectDoorTerminal(IMyEntity owner, string dummyName, MyModelDummy dummyData, int key)
 {
     Door        = (MyDoor)owner;
     LocalMatrix = dummyData.Matrix;
 }
Example #6
0
 public void Close()
 {
     MyDoor.ApplyAction("Open_Off");
 }
 public MyUseObjectDoorTerminal(IMyEntity owner, string dummyName, MyModelDummy dummyData, uint key)
 {
     Door = (MyDoor)owner;
     LocalMatrix = dummyData.Matrix;
 }
    // Collisions
    public void OnCollisionEnter2D(Collision2D collision)
    {
        string tag = collision.gameObject.tag;

        if (tag == "Stake")
        {
            Destroy(collision.gameObject);
            GameObject.FindObjectOfType <AudioManager>().Play("Take Item");
            weapon.SetActive(true);
        }

        if (tag == "Door")
        {
            MyDoor md = collision.gameObject.GetComponent <MyDoor>();
            if (md.opened)
            {
                if (md.bossDoor)
                {
                    PlayerPrefs.SetInt("Lifes", health);
                    PlayerPrefs.SetInt("Leaves", leaves);
                    sceneName = "BossFight";
                    StartCoroutine(LoadScene());
                }

                else
                {
                    changeRoom(md.side, md.roomTo);
                }
            }
            else
            {
                FixDirection();
            }
        }

        if (tag == "Trap" || tag == "Enemy" || tag == "Bullet")
        {
            hit     = true;
            health -= 1;
            main.transform.parent.GetComponent <Animator>().SetTrigger("shake");
            GameObject.FindObjectOfType <AudioManager>().Play("Hurt");

            if (health <= 0)
            {
                dead = true;
                deathCanvas.gameObject.SetActive(true);
                normalCanvas.enabled = false;
                deathCanvas.GetComponent <Animator>().SetTrigger("Appear");
                transform.GetComponent <Rigidbody2D>().simulated = false;
                transform.GetComponent <BoxCollider2D>().enabled = false;
                weapon.SetActive(false);
                hit = false;
                ani.SetBool("Death", true);

                PlayerPrefs.SetInt("Lifes", 6);
                PlayerPrefs.SetInt("Leaves", 0);
            }
        }

        if (tag == "Leave")
        {
            GameObject.FindObjectOfType <AudioManager>().Play("Take Item");

            Destroy(collision.gameObject);

            if (leaves < 12)
            {
                leaves += 1;
            }
        }

        if (tag == "Life")
        {
            if (health < 6)
            {
                Destroy(collision.gameObject);
                health += 1;
                GameObject.FindObjectOfType <AudioManager>().Play("Take Item");
            }
        }
    }
Example #9
0
 public MyUseObjectDoorTerminal(IMyEntity owner, string dummyName, MyModelDummy dummyData, uint key) : base(owner, dummyData)
 {
     this.Door        = (MyDoor)owner;
     this.LocalMatrix = dummyData.Matrix;
 }
Example #10
0
 public MySyncDoor(MyDoor block)
 {
     m_block = block;
 }
 public MyUseObjectDoorTerminal(MyCubeBlock owner, string dummyName, MyModelDummy dummyData, int key)
 {
     Door = (MyDoor)owner;
     LocalMatrix = dummyData.Matrix;
 }
Example #12
0
        private bool IsPressurized(IMySlimBlock block, Vector3I pos, Vector3 normal)
        {
            var def = (MyCubeBlockDefinition)block.BlockDefinition;

            if (def.BuildProgressModels.Length > 0)
            {
                MyCubeBlockDefinition.BuildProgressModel buildProgressModel = def.BuildProgressModels[def.BuildProgressModels.Length - 1];
                if (block.BuildLevelRatio < buildProgressModel.BuildRatioUpperBound)
                {
                    return(false);
                }
            }
            Matrix matrix;

            block.Orientation.GetMatrix(out matrix);
            matrix.TransposeRotationInPlace();
            Vector3 vector   = Vector3.Transform(normal, matrix);
            Vector3 position = Vector3.Zero;

            if (block.FatBlock != null)
            {
                position = pos - block.FatBlock.Position;
            }
            Vector3 value = Vector3.Transform(position, matrix) + def.Center;
            bool    flag  = def.IsCubePressurized[Vector3I.Round(value)][Vector3I.Round(vector)];

            if (flag)
            {
                return(true);
            }
            if (block.FatBlock != null)
            {
                MyCubeBlock fatBlock = (MyCubeBlock)block.FatBlock;
                bool        result;
                if (fatBlock is MyDoor)
                {
                    MyDoor myDoor = fatBlock as MyDoor;
                    if (!myDoor.Open)
                    {
                        MyCubeBlockDefinition.MountPoint[] mountPoints = def.MountPoints;
                        for (int i = 0; i < mountPoints.Length; i++)
                        {
                            MyCubeBlockDefinition.MountPoint mountPoint = mountPoints[i];
                            if (vector == mountPoint.Normal)
                            {
                                result = false;
                                return(result);
                            }
                        }
                        return(true);
                    }
                    return(false);
                }
                else if (fatBlock is MyAdvancedDoor)
                {
                    MyAdvancedDoor myAdvancedDoor = fatBlock as MyAdvancedDoor;
                    if (myAdvancedDoor.FullyClosed)
                    {
                        MyCubeBlockDefinition.MountPoint[] mountPoints2 = def.MountPoints;
                        for (int j = 0; j < mountPoints2.Length; j++)
                        {
                            MyCubeBlockDefinition.MountPoint mountPoint2 = mountPoints2[j];
                            if (vector == mountPoint2.Normal)
                            {
                                result = false;
                                return(result);
                            }
                        }
                        return(true);
                    }
                    return(false);
                }
                else if (fatBlock is MyAirtightSlideDoor)
                {
                    MyAirtightDoorGeneric myAirtightDoorGeneric = fatBlock as MyAirtightDoorGeneric;
                    if (myAirtightDoorGeneric.IsFullyClosed && vector == Vector3.Forward)
                    {
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    if (!(fatBlock is MyAirtightDoorGeneric))
                    {
                        return(false);
                    }
                    MyAirtightDoorGeneric myAirtightDoorGeneric2 = fatBlock as MyAirtightDoorGeneric;
                    if (myAirtightDoorGeneric2.IsFullyClosed && (vector == Vector3.Forward || vector == Vector3.Backward))
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            return(false);
        }