?? class_door.php
字號:
<?php/*** Netlands World Server is the coordinator of the VR in the Netlands Project* Copyright (C) 2002 Ricard Pillosu* * This program is free software; you can redistribute it and/or* modify it under the terms of the GNU General Public License* as published by the Free Software Foundation; either version 2* of the License, or (at your option) any later version.* * This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.* * You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*//* vim: set expandtab tabstop=4 shiftwidth=4 *//*** Class door, the links between the rooms** With this class we define the invisible, abstract link between the rooms.* The only way to moving in the VR is using this "exits" to another room.* Thay can have a lot of properties (open, closed, transparent, etc...)** @see entity* @see room** @version $Id: class_door.php,v 1.4 2002/09/29 12:31:59 doneval Exp $* @author Ricard Pillosu <ricardpillosu@dorna.com>* @copyright Ricard Pillosu 2002* @since Sun, 04 Aug 2002 20:00:41 +0200*/class door extends entity { /** * @var object References to the room where this door leads */ private $target; /** * Init vars * @param object $entity_list the reference to the list where I belong * @param string $key The key to be used by this entity */ function __construct(&$entity_list, $key = NULL) { parent::__construct($entity_list, $key); $this->type = entity_list::T_DOOR; $this->target = NULL; } /** * Update game vars array */ function update_game_vars($vars_to_update) { // Filter use of target_id foreach(array_keys($vars_to_update) as $var_to_update) { switch($var_to_update) { case "target_id": $target_id = $vars_to_update["target_id"]; if($this->set_target_id($target_id) == FALSE) { unset($vars_to_update); } break; } } // Add the rest of non-important variables $this->game_vars = array_merge($this->game_vars, $vars_to_update); return(TRUE); } function &get_target() { return($this->target); } function set_target_id($key) { $entity = & $this->entity_list->get_entity($key, FALSE); if($entity == FALSE) { return(FALSE); } $this->target = & $entity; return(TRUE); } function transport_entity(&$entity) { // Check that $this->target is OK $this->entity_list->is_entity($this->target); // Check that the entity and I are in the same place if($this->parent->is_my_child($entity, FALSE) == FALSE) { throw new exception("entity and door are not in same place"); } // Check that $this->target is OK $this->entity_list->is_entity($this->target); // Move it! $this->entity_list->move_entity_to($entity, $this->target, $this); // Ok all return(TRUE); }}?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -