Example #1
0
 /// <summary>
 /// Attach this object property to Player
 /// </summary>
 /// <param name="player">Catchers object</param>
 public void Attach(Player player)
 {
     player.Health += quantity;
 }
Example #2
0
 /// <summary>
 /// Add another gun to the arms list
 /// </summary>
 /// <param name="player">Jogador</param>
 public virtual void Attach(Player player)
 {
     player.Add(this);
     this.isCatched = true;
     this.owner = player;
     this.ModelMesh.Tag = null;
 }
        /// <summary>
        /// Gets players attibutes from XML document
        /// </summary>
        /// <param name="xmlDoc"></param>
        public static void LoadPlayerAttributes(XmlDocument xmlDoc, float aspectRatio, 
            ref CollisionCameraPerson camera, ref Player player)
        {
            Debug.Assert(xmlDoc != null);

            //Searchs by a "player" node in XML
            XmlNodeList nodeList = xmlDoc.GetElementsByTagName("player");

            Debug.Assert(nodeList.Count != 0);

            XmlElement nodeElement = (XmlElement)nodeList.Item(0);
            Single[] playerAttributes = new Single[10];

            try
            {
                //Get player settings
                playerAttributes[0] = Convert.ToSingle(nodeElement.GetAttribute("positionX"));
                playerAttributes[1] = Convert.ToSingle(nodeElement.GetAttribute("positionY"));
                playerAttributes[2] = Convert.ToSingle(nodeElement.GetAttribute("positionZ"));
                playerAttributes[3] = Convert.ToSingle(nodeElement.GetAttribute("width"));
                playerAttributes[4] = Convert.ToSingle(nodeElement.GetAttribute("height"));
                playerAttributes[5] = Convert.ToSingle(nodeElement.GetAttribute("step_height"));
                playerAttributes[6] = Convert.ToSingle(nodeElement.GetAttribute("head_height"));
                playerAttributes[7] = Convert.ToSingle(nodeElement.GetAttribute("up_and_rotation"));
                playerAttributes[8] = Convert.ToSingle(nodeElement.GetAttribute("gravity"));
                playerAttributes[9] = Convert.ToSingle(nodeElement.GetAttribute("jump_height"));
            }
            catch (InvalidCastException e)
            {
                Log.Write("Scene constructor: InvalidCastExpcetion raised (did you forget some player setting?)");
                Log.Write(e.Message);
            }

            Vector3 initialPosition = new Vector3(playerAttributes[0], playerAttributes[1], playerAttributes[2]);

            camera = new CollisionCameraPerson(initialPosition,  //position
                                                Vector3.Left, //lookat
                                                MathHelper.ToRadians(60), //field of vision
                                                aspectRatio, //aspect ratio
                                                playerAttributes[3], //width default
                                                playerAttributes[4], //height
                                                playerAttributes[5], //step height
                                                playerAttributes[6], //head height
                                                playerAttributes[7], //up and down rotation
                                                playerAttributes[8], //gravity
                                                playerAttributes[9]); //jump height

            player = new Player(100,3, ref camera);
            player.Width = playerAttributes[3];
            player.Height = playerAttributes[4];
        }
Example #4
0
 /// <summary>
 /// Attach this object property to Player
 /// </summary>
 /// <param name="player">Catchers object</param>
 public void Attach(Player player)
 {
     player.AddBulletsToGun( this.GunType, this.quantity );
 }