Пример #1
0
        internal void Walk(Point point)
        {
            //Move Hero and open doors when bumped on
            Point destination = hero.Position + point;

            if (Map.ContainsKey(destination))
            {
                if (Map[destination].Info.BlocksMove == true)
                {
                    if (Map[destination] is IOpenable)
                    {
                        IOpenable d = Map[destination] as IOpenable;
                        d.Open();

                        Map[destination].RemoveCellFromView(this[destination.X, destination.Y]);
                        Map[destination].RenderToCell(this[destination.X, destination.Y]);
                        UpdateFov();
                    }
                    MessagesConsole.Instance.PrintMessage("Blocked Move!");
                    return;
                }
                // Handle render to new pos and unrendering from previous pos
                if (new Rectangle(0, 0, Width - 1, Height - 1).Contains(destination))
                {
                    hero.UnRenderFromCell(ActorLayer[hero.Position.X, hero.Position.Y]);
                    hero.Position = destination;
                    MessagesConsole.Instance.PrintMessage("You see here: " + Map[destination].Info.Description);
                    UpdateFov();
                    hero.RenderToCell(ActorLayer[destination.X, destination.Y]);
                    // Update Stats screen
                    hero.OnChangedEvent();
                }
            }
        }
Пример #2
0
    protected void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag != "Player")
        {
            if (coll.gameObject.tag == "Floor")
            {
                audioSource.PlayOneShot(hitfloor, volumeScale);
            }
            else if (coll.gameObject.tag == "Wall")
            {
                audioSource.PlayOneShot(hitfloor, volumeScale);
            }
            dangerous = false;
        }

        IOpenable openable = coll.gameObject.GetComponent <IOpenable>();
        IKillable killable = coll.gameObject.GetComponent <IKillable>();

        if (openable != null)
        {
            audioSource.PlayOneShot(openDoor, 0.5f);
            openable.Open();
            Destroy(gameObject);
        }

        if (killable != null && dangerous)
        {
            audioSource.PlayOneShot(hitPlayer, volumeScale);
            killable.Kill();
            Destroy(gameObject);
        }
    }
Пример #3
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        IOpenable openable = coll.gameObject.GetComponent <IOpenable>();

        if (openable != null)
        {
            openable.Open();
        }
    }
Пример #4
0
 static void OpenClose(IOpenable d)
 {
     if (d is IOpenable)
     {
         if (d.IsOpen)
         {
             d.Close();
         }
         else
         {
             d.Open();
         }
     }
     else
     {
         Console.WriteLine("not realizeted interface IOpenable");
     }
 }
        public static Toil Open(TargetIndex openableInd)
        {
            Toil open = new Toil();

            open.initAction = delegate
            {
                Pawn  actor = open.actor;
                Thing thing = actor.CurJob.GetTarget(openableInd).Thing;
                actor.Map.designationManager.DesignationOn(thing, DesignationDefOf.Open)?.Delete();
                IOpenable openable = (IOpenable)thing;
                if (openable.CanOpen)
                {
                    openable.Open();
                    actor.records.Increment(RecordDefOf.ContainersOpened);
                }
            };
            open.defaultCompleteMode = ToilCompleteMode.Instant;
            return(open);
        }
 // IOpenable
 public RedirectResult ToogleDoor(int id = 0)
 {
     if (id != 0)
     {
         Device device = db.GetDeviceById(id);
         if (device != null && device is IOpenable)
         {
             IOpenable door = (IOpenable)device;
             if (door.IsOpen)
             {
                 door.Close();
             }
             else
             {
                 door.Open();
             }
             db.UpdateDeviceById(id, device);
         }
     }
     return(Redirect("/Home/Index"));
 }
Пример #7
0
 /*************************************************************************/
 public Acquire(IOpenable objOpenable)
 {
     m_objOpenable = objOpenable;
     m_objOpenable.Open();
 }
Пример #8
0
 static void OpenTheDoorByThe(IOpenable way)
 {
     way.Open();
 }
Пример #9
0
Файл: Open.cs Проект: crybx/mud
        public IResult PerformCommand(IMobileObject performer, ICommand command)
        {
            if (command.Parameters.Count == 0)
            {
                return(new Result(false, "While you ponder what to open you let you mouth hang open.  Hey you did open something!"));
            }

            IParameter  parameter = command.Parameters[0];
            IBaseObject foundItem = GlobalReference.GlobalValues.FindObjects.FindObjectOnPersonOrInRoom(performer, parameter.ParameterValue, parameter.ParameterNumber, true, true, false, false, true);

            if (foundItem != null)
            {
                IDoor door = foundItem as IDoor;

                if (door != null)
                {
                    IResult result = ProcessDoor(performer, door);
                    if (result != null)
                    {
                        return(result);
                    }

                    if (door.Linked)
                    {
                        IRoom otherRoom = GlobalReference.GlobalValues.World.Zones[door.LinkedRoomId.Zone].Rooms[door.LinkedRoomId.Id];
                        IDoor otherDoor = null;
                        switch (door.LinkedRoomDirection)
                        {
                        case Direction.North:
                            otherDoor = otherRoom.North.Door;
                            break;

                        case Direction.East:
                            otherDoor = otherRoom.East.Door;
                            break;

                        case Direction.South:
                            otherDoor = otherRoom.South.Door;
                            break;

                        case Direction.West:
                            otherDoor = otherRoom.West.Door;
                            break;

                        case Direction.Up:
                            otherDoor = otherRoom.Up.Door;
                            break;

                        case Direction.Down:
                            otherDoor = otherRoom.Down.Door;
                            break;
                        }

                        if (otherDoor != null)
                        {
                            otherDoor.Locked = false;
                            otherDoor.Opened = true;
                        }
                    }
                    return(door.Open());
                }
                else
                {
                    IOpenable openable = foundItem as IOpenable;

                    if (openable != null)
                    {
                        return(openable.Open());
                    }
                }

                return(new Result(false, "You found what you were looking for but could not figure out how to open it."));
            }
            else
            {
                return(new Result(false, "You were unable to find that what you were looking for."));
            }
        }