Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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());
        }
Beispiel #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());
        }
Beispiel #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);
            }
        }
Beispiel #6
0
        public Player(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int avatarId)
			: base(world, avatarDefinition, avatarId)
        {
            inventory = new Inventory(this);
        }
        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;
        }
Beispiel #8
0
		public void Create(AvatarDefinition[] avatarDefinitions)
		{
			this.avatarDefinitions = avatarDefinitions;
		}
Beispiel #9
0
 public Player(CubeWorld.World.CubeWorld world, AvatarDefinition avatarDefinition, int avatarId)
     : base(world, avatarDefinition, avatarId)
 {
     inventory = new Inventory(this);
 }