상속: MonoBehaviour
예제 #1
0
        private void InitDoor()
        {
            u1 = new OfficeUser() { Birthday = DateTime.Today, EmployeeNumber = "12046", Gender = Gender.Male, Name = "Devin" };
             t1 = new Teacher() { Birthday = Convert.ToDateTime("1984-1-1"), EmployeeNumber = "12334", Gender = Gender.Female, Major = "Math", Name = "StevenMath" };
            Session.SaveOrUpdate(u1);
            Session.SaveOrUpdate(t1);
            Student s1 = new Student() { Birthday = Convert.ToDateTime("1983-12-20"), Gender = Gender.Male, Name = "Jack" };
            Session.SaveOrUpdate(s1);
            Lab l1 = new Lab() { Address = "Teaching Tower 1", Description = "For chemistry", Size = 70, LabSubject = "Primary Chemistry" };
            Classroom cr1 = new Classroom() { Address = "Teaching Building 2", Description = "Common Room", RoomNumber = "402", Size = 150 };
            Session.SaveOrUpdate(l1);
            Session.SaveOrUpdate(cr1);
            Session.Flush();

            Education e1=new Education(){Employee = t1,GraduateYear = 2003,University = "UESTC"};
            Education e11 = new Education() { Employee = t1, GraduateYear = 2007, University = "BJU" };
            Education e2 = new Education() { Employee = u1, GraduateYear = 2001, University = "USTC" };
            t1.Educations.Add(e1);
            t1.Educations.Add(e11);
            u1.Educations.Add(e2);
            DoorKey doorKey = new DoorKey() { Name = "401 Key" };
            doorKey.Employees = new List<Employee>();
            doorKey.Employees.Add(u1);
            doorKey.Employees.Add(t1);
            Session.SaveOrUpdate(doorKey);
            Session.Flush();
        }
예제 #2
0
    public override bool use()
    {
        trigger_base trigger = null;

        //If a door has a link and the link is to something that is not a lock then it is a trigger that I need to activae
        if (link != 0)
        {
            ObjectInteraction linkedObject = ObjectLoader.getObjectIntAt(link);
            if (linkedObject != null)
            {
                if (linkedObject.GetItemType() != ObjectInteraction.LOCK)
                {
                    trigger = linkedObject.GetComponent <trigger_base>();
                }
            }
        }

        if (CurrentObjectInHand != null)
        {
            ActivateByObject(CurrentObjectInHand);
            //Clear the object in hand
            //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault;
            CurrentObjectInHand = null;
            if (trigger != null)
            {
                trigger.Activate(this.gameObject);
            }
            return(true);
        }
        else
        {        //Normal Usage
            PlayerUse = true;
            if ((UWCharacter.AutoKeyUse) && (locked()))
            {//Try each key in the players inventory to see if it can open the door
                foreach (Transform t in GameWorldController.instance.InventoryMarker.transform)
                {
                    if (t.gameObject.GetComponent <DoorKey>() != null)
                    {
                        DoorKey key = t.gameObject.GetComponent <DoorKey>();
                        if (key.KeyId == KeyIndex)
                        {
                            ActivateByObject(key.objInt());
                            if (trigger != null)
                            {
                                trigger.Activate(this.gameObject);
                            }
                            PlayerUse = false;
                            return(true);
                        }
                    }
                }
            }

            Activate(this.gameObject);
            PlayerUse = false;
            return(true);
        }
    }
예제 #3
0
        public void GeneratePrison(Vector2 position, GameData data)
        {
            const float doorSize = 96;
            const float doorAscent = 64;
            const float prisonWidth = 576;
            const float prisonHeight = 576;
            const float halfWidth = prisonWidth / 2;
            const float halfHeight = prisonHeight / 2;
            const float wallWidth = 16;
            const float wallHalfWidth = wallWidth / 2;

            const float doorTopHeight = doorSize + doorAscent;
            const float wallAboveDoorSize = (prisonHeight - (doorAscent + doorSize));
            const float halfWallAboveDoorSize = wallAboveDoorSize / 2;

            const float cellSize = prisonWidth / 3;
            const float cellDoorSize = 96;
            float internalWallHeight = position.Y + halfHeight - cellSize - wallHalfWidth;
            float internalWallSize = cellSize - cellDoorSize;

            //floor
            EntList.Add(new BldgFloor(position, new Vector2(prisonWidth, prisonHeight)));

            //solid walls
            EntList.Add(new BldgWall(position + new Vector2(0, halfHeight + wallHalfWidth), new Vector2(prisonWidth + 2 * wallWidth, wallWidth), 0));
            EntList.Add(new BldgWall(position - new Vector2(0, halfHeight + wallHalfWidth), new Vector2(prisonWidth + 2 * wallWidth, wallWidth), 0));
            EntList.Add(new BldgWall(position + new Vector2(halfWidth + wallHalfWidth, 0), new Vector2(prisonHeight, wallWidth), 3 * MathHelper.PiOver2));

            //wall w/ entrance
            EntList.Add(new BldgWall(position - new Vector2(halfWidth + wallHalfWidth, halfHeight - (doorAscent / 2)), new Vector2(doorAscent, wallWidth), MathHelper.PiOver2));
            EntList.Add(new BldgWall(position - new Vector2(halfWidth + wallHalfWidth, halfHeight - doorTopHeight - halfWallAboveDoorSize), new Vector2(wallAboveDoorSize, wallWidth), MathHelper.PiOver2));

            //internal walls
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + cellDoorSize + (internalWallSize / 2), internalWallHeight), new Vector2(cellSize - cellDoorSize, wallWidth), 0));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + cellSize + cellDoorSize + (internalWallSize / 2), internalWallHeight), new Vector2(cellSize - cellDoorSize, wallWidth), 0));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + 2 * cellSize + cellDoorSize + (internalWallSize / 2), internalWallHeight), new Vector2(cellSize - cellDoorSize, wallWidth), 0));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + cellSize - wallHalfWidth, internalWallHeight + (cellSize / 2) + wallHalfWidth), new Vector2(cellSize, wallWidth), 3 * MathHelper.PiOver2));
            EntList.Add(new BldgWall(new Vector2(position.X - halfWidth + 2 * cellSize - wallHalfWidth, internalWallHeight + (cellSize / 2) + wallHalfWidth), new Vector2(cellSize, wallWidth), 3 * MathHelper.PiOver2));

            //key
            if (!data.PrisonKeyFound)
            {
                DoorKey prisonKey = new DoorKey(position + new Vector2(halfWidth, -halfHeight) - new Vector2(32, -32), "prison door key");
                PickupTriggers.Add(new TriggerPickup(prisonKey.Position, new Vector2(64, 64), prisonKey));
                EntList.Add(prisonKey);
            }

            Note n = new Note(position - new Vector2(halfWidth, halfHeight) + new Vector2(64, 64));
            EntList.Add(n);
            ReadingTriggers.Add(new TriggerReading(n.Position, new Vector2(64, 64), Notes.PrisonNote));

            //doors
            Door prisonDoor = new Door(new Vector2(position.X - halfWidth + (cellDoorSize / 2), internalWallHeight), 0, "prison door");
            if (!data.PrisonDoorOpened)
            {
                EntList.Add(prisonDoor);
            }
            else
                prisonDoor.Unload();
            EntList.Add(new Door(new Vector2(position.X - halfWidth + cellSize + (cellDoorSize / 2), internalWallHeight), 0));
            EntList.Add(new Door(new Vector2(position.X - halfWidth + cellSize * 2 + (cellDoorSize / 2), internalWallHeight), 0));

            DoorOpenTriggers.Add(new TriggerDoorOpen(prisonDoor.Position, new Vector2(96, 96), prisonDoor, "prison door key"));

            //fuse
            if (!data.FuseFound)
            {
                Fuse f = new Fuse(new Vector2(position.X - halfWidth + (cellSize / 2), internalWallHeight + (cellSize / 2)));
                EntList.Add(f);
                PickupTriggers.Add(new TriggerPickup(f.Position, new Vector2(64, 64), f));
            }
        }
예제 #4
0
        public void SetUp()
        {
            ReBuildDatabase();
            OfficeUser u1=new OfficeUser(){Birthday = DateTime.Today,EmployeeNumber = "12046",Gender = Gender.Male,Name = "Devin"};
            Teacher t1=new Teacher(){Birthday = Convert.ToDateTime("1984-1-1"),EmployeeNumber = "12334",Gender = Gender.Female,Major = "Math",Name = "StevenMath"};
            Session.SaveOrUpdate(u1);
            Session.SaveOrUpdate(t1);
            Student s1=new Student(){Birthday = Convert.ToDateTime("1983-12-20"),Gender = Gender.Male,Name = "Jack"};
            Session.SaveOrUpdate(s1);
            Lab l1=new Lab(){Address = "Teaching Tower 1",Description = "For chemistry",Size = 70,LabSubject = "Primary Chemistry"};
            Classroom cr1=new Classroom(){Address = "Teaching Building 2",Description = "Common Room",RoomNumber = "402",Size = 150};
            Session.SaveOrUpdate(l1);
            Session.SaveOrUpdate(cr1);
            Session.Flush();

            DoorKey doorKey = new DoorKey() { Name = "401 Key" };
            doorKey.Employees = new List<Employee>();
            doorKey.Employees.Add(u1);
            doorKey.Employees.Add(t1);
            Session.SaveOrUpdate(doorKey);
            Session.Flush();
        }
예제 #5
0
    public override bool ActivateByObject(ObjectInteraction ObjectUsed)
    {    //Code for handling otherobjects used on this object
         //Doors can be used by keys, picks and spikes.
        //ObjectInteraction objIntUsed = ObjectUsed.GetComponent<ObjectInteraction>();
        if (ObjectUsed != null)
        {
            switch (ObjectUsed.GetItemType())
            {
            case ObjectInteraction.KEY:                     //Key
                DoorKey dk = ObjectUsed.GetComponent <DoorKey>();
                if (dk != null)
                {
                    if (state() == true)
                    {
                        //Door is already open
                        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 6));
                        return(true);
                    }
                    ObjectInteraction doorlock = getLockObjInt();
                    if (doorlock == null)
                    {
                        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 3));
                        return(false);
                    }
                    if ((doorlock.link & 0x3F) == dk.owner)                         //This is a valid key for the door.
                    {
                        ToggleLock(true);
                        if (locked() == true)
                        {                                        //Locked message
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 4));
                        }
                        else
                        {                                        //Unlockedmessage
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 5));
                        }
                        return(true);
                    }
                    else
                    {
                        if (link == 53)
                        {                                //There is no lock
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 3));
                        }
                        else
                        {                                //That is the wrong key.
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 2));
                        }
                        return(true);
                    }
                }
                break;

            case ObjectInteraction.LOCKPICK:                            //lockpick
            {
                //lock pick skill check is based on the zpos of the "lock" object * 3 vs the players (lockpick skill + 1)
                //Locks cannot be picked if the zpos is 0xE or greater. In either case the skillcheck is attempted.
                ObjectInteraction LockObject = getLockObjInt();
                if (LockObject != null)
                {
                    int skillvalue  = UWCharacter.Instance.PlayerSkills.PickLock + 1;
                    int targetvalue = LockObject.zpos * 3;
                    Skills.SkillRollResult skillroll = Skills.SkillRoll(skillvalue, targetvalue);

                    if (LockObject.zpos >= 0xE)
                    {        //unpickable
                        if (skillroll == Skills.SkillRollResult.CriticalFailure)
                        {
                            BreakLockPick(ObjectUsed);
                        }
                        else
                        {
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_your_lockpicking_attempt_failed_));
                        }
                    }
                    else
                    {
                        switch (skillroll)
                        {
                        case Skills.SkillRollResult.CriticalFailure:
                        {
                            BreakLockPick(ObjectUsed);
                            break;
                        }

                        case Skills.SkillRollResult.Failure:
                        {
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_your_lockpicking_attempt_failed_));
                            break;
                        }

                        case Skills.SkillRollResult.Success:
                        case Skills.SkillRollResult.CriticalSuccess:
                        {
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_succeed_in_picking_the_lock_));
                            UnlockDoor(true);
                            break;
                        }
                        }
                    }
                }
                else
                {
                    UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 3));        //There is no lock on that.
                }
            }
            break;

            //{
            //if (Pickable==true)
            //	{
            //		if (UWCharacter.Instance.PlayerSkills.TrySkill(Skills.SkillPicklock, Skills.DiceRoll(1,25)))
            //		{
            //		UWHUD.instance.MessageScroll.Add (StringController.instance.GetString (1,StringController.str_you_succeed_in_picking_the_lock_));
            //		UnlockDoor(true);
            //		}
            //	else
            //		{
            //		//Debug.Log ("Picklock failed!");
            //		UWHUD.instance.MessageScroll.Add (StringController.instance.GetString (1,StringController.str_your_lockpicking_attempt_failed_));
            //		//objIntUsed.consumeObject();
            //		}
            //	}
            //else
            //	{
            //		UWHUD.instance.MessageScroll.Add (StringController.instance.GetString (1,StringController.str_your_lockpicking_attempt_failed_));
            //	}
            //break;
            //}
            case ObjectInteraction.SPIKE:
            {
                if (Spike())
                {
                    ObjectUsed.consumeObject();
                }
                break;
            }

            default:
                return(false);
            }
        }
        else
        {
            return(false);
        }
        return(true);
    }
예제 #6
0
    public override bool ActivateByObject(GameObject ObjectUsed)
    {    //Code for handling otherobjects used on this object
         //Doors can be used by keys, picks and spikes.
        //ObjectInteraction objIntThis = this.GetComponent<ObjectInteraction>();
        ObjectInteraction objIntUsed = ObjectUsed.GetComponent <ObjectInteraction>();

        if (objIntUsed != null)
        {
            switch (objIntUsed.ItemType)
            {
            case ObjectInteraction.KEY:                     //Key
                DoorKey dk = ObjectUsed.GetComponent <DoorKey>();
                if (dk != null)
                {
                    if (state == true)
                    {
                        //Door is already open
                        ml.Add(playerUW.StringControl.GetString(1, 6));
                        return(true);
                    }

                    if (KeyIndex == dk.KeyId)                         //This is a valid key for the door.
                    {
                        ToggleLock();
                        if (locked == true)
                        {                                        //Locked message
                            ml.Add(playerUW.StringControl.GetString(1, 4));
                        }
                        else
                        {                                        //Unlockedmessage
                            ml.Add(playerUW.StringControl.GetString(1, 5));
                        }
                        return(true);
                    }
                    else
                    {
                        if (KeyIndex == 53)
                        {                                //There is no lock
                            ml.Add(playerUW.StringControl.GetString(1, 3));
                        }
                        else
                        {                                //That is the wrong key.
                            ml.Add(playerUW.StringControl.GetString(1, 2));
                        }
                        return(true);
                    }
                }
                break;

            case ObjectInteraction.LOCKPICK:                            //lockpick
            {
                if (Pickable == true)
                {
                    if (playerUW.PlayerSkills.TrySkill(Skills.SkillPicklock, objIntUsed.Quality))
                    {
                        ml.Add(playerUW.StringControl.GetString(1, 121));
                        UnlockDoor();
                    }
                    else
                    {
                        //Debug.Log ("Picklock failed!");
                        ml.Add(playerUW.StringControl.GetString(1, 120));
                        objIntUsed.consumeObject();
                    }
                }
                else
                {
                    ml.Add(playerUW.StringControl.GetString(1, 120));
                }
                break;
            }

            case ObjectInteraction.SPIKE:
            {
                if (Spiked == false)
                {
                    //000~001~128~You can only spike closed doors.
                    //000~001~129~The door is now spiked closed.
                    //000~001~130~Please select door to spike...
                    //000~001~131~The door is spiked.
                    if (state == false)
                    {                                    //Closed door
                        ml.Add(playerUW.StringControl.GetString(1, 129));
                        Spiked = true;
                        objIntUsed.consumeObject();
                    }
                    else
                    {
                        ml.Add(playerUW.StringControl.GetString(1, 128));
                    }
                }
                else
                {
                    ml.Add(playerUW.StringControl.GetString(1, 131));
                }
                return(true);
            }

            default:
                return(false);
            }
        }
        else
        {
            return(false);
        }
        return(true);
    }
예제 #7
0
        public Level(string levelName, string previousLevel, string checkpointLevel)
        {
            Bitmap bmp = new Bitmap(string.Format("Levels/{0}.bmp", levelName));

            for (int x = 0, nX = bmp.Width; x < nX; x++)
            {
                for (int y = 0, nY = bmp.Height; y < nY; y++)
                {
                    var color = bmp.GetPixel(x, y);

                    switch (color.Name)
                    {
                    case "ffffffff":
                        // no object
                        break;

                    case "ff000000":
                        var block = new Block(x * 10, y * 10);

                        _bodies.Add(block);
                        break;

                    case "ff00ff00":
                        var checkpoint = new Checkpoint(x * 10, y * 10, levelName == checkpointLevel);

                        _bodies.Add(checkpoint);

                        if (previousLevel == null)
                        {
                            AddPlayer(x, y, 1);
                            Player.ResetPlayer();
                        }
                        break;

                    case "ffff0000":
                        var spikes = new Spikes(x * 10, (y * 10) + 1);

                        _bodies.Add(spikes);
                        break;

                    case "ff00a0c0":
                        var jumper = new Jumper(x * 10, y * 10);

                        jumper.Target = Player;

                        _bodies.Add(jumper);
                        break;

                    case "ff0000ff":
                        var enemy = new Spider(x * 10, y * 10);

                        enemy.Target = Player;

                        _bodies.Add(enemy);
                        break;

                    case "ffa6caf0":
                        var something = new Charger(x * 10, y * 10);

                        something.Target = Player;

                        _bodies.Add(something);
                        break;

                    case "ff000040":
                        var stomper = new Stomper((x * 10) - 20, (y * 10) - 11);

                        stomper.Target = Player;

                        var stomperGift = new DoorKey(0, 0);
                        stomperGift.LockID         = 4;
                        stomperGift.Mass           = 5;
                        stomperGift.IsStatic       = false;
                        stomperGift.Drag           = 0.01;
                        stomperGift.CollisionGroup = 8055;

                        stomper.Gift = stomperGift;

                        _boss = stomper;
                        _bodies.Add(stomper);
                        break;

                    case "ffffff00":
                        var star = new Star(x * 10, y * 10);

                        _bodies.Add(star);
                        break;

                    case "ffff00ff":
                        var rightDoor = new RightDoor(x * 10, (y * 10) - 6, levelName, Direction.Left);

                        if (previousLevel == (rightDoor as Door).Level)
                        {
                            AddPlayer(x + (int)((rightDoor as Door).Start), y, -1);
                        }

                        if (levelName == "0-4")
                        {
                            rightDoor.IsLocked = true;
                            rightDoor.LockID   = 3;
                            rightDoor.SetTexture();
                        }

                        _bodies.Add(rightDoor);
                        break;

                    case "ff800080":
                        var leftDoor = new LeftDoor(x * 10, (y * 10) - 6, levelName, Direction.Right);

                        if (previousLevel == (leftDoor as Door).Level)
                        {
                            AddPlayer(x + (int)((leftDoor as Door).Start), y, 1);
                        }

                        if (levelName == "0-0")
                        {
                            leftDoor.IsLocked = true;
                            leftDoor.LockID   = 4;
                            leftDoor.IsExit   = true;
                            leftDoor.SetTexture();
                        }

                        if (levelName == "2-2")
                        {
                            leftDoor.IsLocked = true;
                            leftDoor.LockID   = 2;
                            leftDoor.SetTexture();
                        }

                        _bodies.Add(leftDoor);
                        break;

                    case "ff8000c0":
                        var downDoor = new DownDoor(x * 10, (y * 10) - 6, levelName, Direction.Left);

                        if (previousLevel == (downDoor as Door).Level)
                        {
                            AddPlayer(x + (int)((downDoor as Door).Start), y, -1);
                        }

                        if (levelName == "2-2")
                        {
                            downDoor.IsLocked = true;
                            downDoor.LockID   = 1;
                            downDoor.SetTexture();
                        }

                        if (levelName == "3-2")
                        {
                            downDoor.IsLocked = true;
                            downDoor.LockID   = 4;
                            downDoor.SetTexture();
                        }

                        _bodies.Add(downDoor);
                        break;

                    case "ffe00080":
                        var upDoor = new UpDoor(x * 10, (y * 10) - 6, levelName, Direction.Right);

                        if (previousLevel == (upDoor as Door).Level)
                        {
                            AddPlayer(x + (int)((upDoor as Door).Start), y, 1);
                        }

                        if (levelName == "4-2")
                        {
                            upDoor.IsLocked = true;
                            upDoor.LockID   = 4;
                            upDoor.SetTexture();
                        }

                        _bodies.Add(upDoor);
                        break;

                    case "ffa0a000":
                        var key = new DoorKey(x * 10, y * 10);

                        switch (levelName)
                        {
                        case "1-1":
                            key.LockID = 2;
                            break;

                        case "2-0":
                            key.LockID = 1;
                            break;

                        case "1-3":
                            key.LockID = 3;
                            break;
                        }

                        _bodies.Add(key);
                        break;

                    case "ffe0c000":
                        if (_player != null && _player.Inventory.HasFlag(InventoryItem.DoubleJump))
                        {
                            break;
                        }

                        var doubleJump = new DoubleJump(x * 10, y * 10);

                        _bodies.Add(doubleJump);
                        break;

                    case "ffc0a000":
                        if (_player != null && _player.Inventory.HasFlag(InventoryItem.Run))
                        {
                            break;
                        }

                        var run = new Run(x * 10, y * 10);

                        _bodies.Add(run);
                        break;

                    case "ffc0e000":
                        if (_player != null && _player.Inventory.HasFlag(InventoryItem.Weapon))
                        {
                            break;
                        }

                        var basicWeapon = new BasicWeapon(x * 10, y * 10);

                        _bodies.Add(basicWeapon);
                        break;

                    case "ffa0c000":
                        if (_player != null && _player.Inventory.HasFlag(InventoryItem.WeaponPower))
                        {
                            break;
                        }

                        var strongWeapon = new StrongWeapon(x * 10, y * 10);

                        _bodies.Add(strongWeapon);
                        break;

                    case "ffe0e040":
                        if (_player != null && _player.Inventory.HasFlag(InventoryItem.WeaponSpeed))
                        {
                            break;
                        }

                        var fastWeapon = new FastWeapon(x * 10, y * 10);

                        _bodies.Add(fastWeapon);
                        break;

                    case "ff608000":
                        if (_player != null && _player.Inventory.HasFlag(InventoryItem.WeaponLength))
                        {
                            break;
                        }

                        var longWeapon = new LongWeapon(x * 10, y * 10);

                        _bodies.Add(longWeapon);
                        break;

                    case "ffc0c0c0":
                        var botBoundry = new BotBoundry(x * 10, y * 10);

                        _bodies.Add(botBoundry);
                        break;

                    case "ff808080":
                        var breakable = new Breakable(x * 10, y * 10);

                        _bodies.Add(breakable);
                        break;

                    case "ffa0a0a4":
                        var bossBoundry = new BossBoundry(x * 10, y * 10);

                        _bodies.Add(bossBoundry);
                        break;

                    default:
                        break;
                    }
                }
            }

            _bodies = _bodies.OrderBy(b => b.DrawOrder).ToList();
        }
 public bool Authenticate(string name, DoorKey token)
 {
 }