Ejemplo n.º 1
0
        public Avatar CreateAvatar(AvatarDefinition avatarDefinition, int objectId, Vector3 pos, bool dispatchWorldListener)
        {
            Avatar avatar;

            if (avatarDefinition.id == "player")
            {
                avatar = new Player(world, avatarDefinition, objectId);
                this.player = avatar as Player;
            }
            else if (avatarDefinition.id == "player_remote")
            {
                avatar = new Player(world, avatarDefinition, objectId);
            }
            else
            {
                avatar = new Avatar(world, avatarDefinition, objectId);
                avatar.AddComponent(new AvatarComponentIA());
            }

            avatar.position = pos;

            avatars.Add(avatar);

            if (dispatchWorldListener)
                world.cwListener.CreateObject(avatar);

            return avatar;
        }
Ejemplo n.º 2
0
        public Avatar CreateAvatar(AvatarDefinition avatarDefinition, int objectId, Vector3 pos, bool dispatchWorldListener)
        {
            Avatar avatar;

            if (avatarDefinition.id == "player")
            {
                avatar      = new Player(world, avatarDefinition, objectId);
                this.player = avatar as Player;
            }
            else if (avatarDefinition.id == "player_remote")
            {
                avatar = new Player(world, avatarDefinition, objectId);
            }
            else
            {
                avatar = new Avatar(world, avatarDefinition, objectId);
                avatar.AddComponent(new AvatarComponentIA());
            }

            avatar.position = pos;

            avatars.Add(avatar);

            if (dispatchWorldListener)
            {
                world.cwListener.CreateObject(avatar);
            }

            return(avatar);
        }
Ejemplo n.º 3
0
        public Avatar(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int objectId)
            : base(objectId)
        {
            this.world      = world;
            this.definition = avatarDefinition;

            this.input = new AvatarInput();

            AddComponent(new AvatarComponentPhysics());
        }
Ejemplo n.º 4
0
        public Avatar(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int objectId)
            : base(objectId)
        {
            this.world = world;
			this.definition = avatarDefinition;

            this.input = new AvatarInput();

            AddComponent(new AvatarComponentPhysics());
        }
Ejemplo n.º 5
0
        public void Load(System.IO.BinaryReader br)
        {
            int n = br.ReadInt32();

            for (int i = 0; i < n; i++)
            {
                string  avatarDefinitionId = br.ReadString();
                int     objectId           = br.ReadInt32();
                Vector3 position           = SerializationUtils.ReadVector3(br);

                AvatarDefinition avatarDefinition = GetAvatarDefinitionById(avatarDefinitionId);

                Avatar avatar = CreateAvatar(avatarDefinition, objectId, position, false);

                avatar.Load(br);

                world.cwListener.CreateObject(avatar);
            }
        }
Ejemplo n.º 6
0
        public Player(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int avatarId)
			: base(world, avatarDefinition, avatarId)
        {
            inventory = new Inventory(this);
        }
Ejemplo n.º 7
0
        private AvatarDefinition ParseAvatarDefinition(XmlElement avatarDefinitionXML)
        {
            AvatarDefinition avatar = new AvatarDefinition();

            avatar.id = GetAttributeStringValue(avatarDefinitionXML, "id");
            avatar.description = GetAttributeStringValue(avatarDefinitionXML, "description");
            avatar.energy = GetAttributeIntValue(avatarDefinitionXML, "energy", 0);
            avatar.sizeInTiles = GetAttributeTilePositionValue(avatarDefinitionXML, "size");

            List<AvatarPartDefinition> parts = new List<AvatarPartDefinition>();

            foreach (XmlElement partXML in GetChildElements(avatarDefinitionXML["Parts"]))
                parts.Add(ParseAvatarPartDefinition(partXML));

            avatar.parts = parts.ToArray();

            return avatar;
        }
Ejemplo n.º 8
0
		public void Create(AvatarDefinition[] avatarDefinitions)
		{
			this.avatarDefinitions = avatarDefinitions;
		}
Ejemplo n.º 9
0
 public Player(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int avatarId)
     : base(world, avatarDefinition, avatarId)
 {
     inventory = new Inventory(this);
 }