Friday, November 30, 2012

Crunch Time

So our project has a lot of cool features but not many of the features are into the game yet, including effects and objectives to make the game playable. In our discussion, we decided that we wanted to do an art lock for Saturday and a programming lock for Monday night. The game is due the following Thursday so this will help us fix any bugs over the next three days. One of the first things was placing all the items on the map.

In our campaign world, this is our character.  Unfortunately, the player avatar will not work until you play on the xbox.  Animations should work properly and the next obstacle is to get images straight from the xbox so it would show the character.  Now that everything is in, the next thing is to debug the game and make the game presentable on Thursday.

Friday, November 23, 2012

Dynamic Class Creator

So I just implemented a very interesting piece of code that will dynamically create an inheritance class dynamically rather than having to make several methods that will each do practically the same thing.  This is a Class Delegate Function and the code looks like the following.


        /**
         * InstantiateCollectible<Item> - Creates a new Collectible on the map
         *  Item - Inheritance Child of Collectible
         *
         * PARAMS
         *  position - Position of the object
         *  rotation - Rotation of the object
         *
         * RETURN
         *  Collectible - Object Player can pick up in the game
         */
        public static Collectible InstantiateCollectible<Item>(Vector3 position, Quaternion rotation) where Item : Collectible
        {
            AvatarDescription description = AvatarDescription.CreateRandom();

            Collectible collectible = (Collectible)Activator.CreateInstance(typeof(Item), description, position, rotation, PlayerStatSheet.AvatarMass);

            collectible.TeamId = 1;

            return collectible;
        }

Friday, November 16, 2012

Collections Manager

I wanted to work with a Singleton Pattern and have a class that can be moved from project to project without having to do much modification in work.  I have come up with a collections manager that keeps track of what players have collected inside of a given level.  The code looks like the following:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

using UPC = System.Type;



namespace NinjaRoyale.Collections

{

    /**

     * Keeps track of all the collections collected inside of the game for any given player

     *

     * UPC - Universal Product Code, Finds out what kind of Collectible an object is

     *

     * Author - Mavin Martin

     * Date   - 11/21/2012

     */

    public class CollectionsManager

    {

        private static CollectionsManager instance = null;



        Dictionary<Entity, Dictionary<UPC, int>> ownerStash;





        /**

         * ===== CollectionsManager =====

         *

         * Uses Singleton Pattern to guarantee only one Collection Manager

         */

        private CollectionsManager()

        {

            ownerStash = new Dictionary<Entity, Dictionary<UPC, int>>();

        }



        /**

         * AddCollectable - Add's Collectable to the player

         *

         * PARAMS

         *  owner - Independent object owning the collectible

         *  item  - Item owned by owner

         */

        public void AddCollectable(Entity owner, Collectible item)

        {

            Dictionary<UPC, int> stash;

            if (!ownerStash.TryGetValue(owner, out stash))

                stash = initiateStash(owner);



            addItemToStash(stash, item);

        }



        /**

         * getStashItems - Get's the stash items owned by a certain owner

         *

         * PARAMS

         *  owner - Independent object owning the stash

         *

         * RETURN

         *  Dictionary<UPC, int> - Stash of items as linked list

         */

        public Dictionary<UPC, int> getStashItems(Entity owner)

        {

            Dictionary<UPC, int> stash;

            if (!ownerStash.TryGetValue(owner, out stash))

                stash = initiateStash(owner);



            return stash;

        }



        /**

         * RemoveCollectible - Removes Collectible from the player. 

         *

         * If you are getting rid of all items for an owner, please call RemoveOwner instead.

         *

         * PARAMS

         *  owner - Independent object owning items

         *  item  - Item belonging to the owner

         */

        public void RemoveCollectible(Entity owner, Collectible item)

        {

            Dictionary<UPC, int> stash;

            ownerStash.TryGetValue(owner, out stash);

            UPC upc = getUPC(item);

            stash.Remove(upc);

        }



        /**

         * RemoveOwner - Removes an owner from the Collections Manager.

         *

         * IMPORTANT NOTE: Owner does not need to add themselves.  This happens immediately when adding collectible

         *

         * PARAMS

         *  owner - the Entity that will own the collectible

         */

        public void RemoveOwner(Entity owner)

        {

            ownerStash.Remove(owner);

        }



        /**

         * addItemToStash - Add's item to the stash for a given player

         *

         * PARAMS

         *  stash - Linked List of items in the stash

         *  item  - Item to be added to the stash

         */

        private void addItemToStash(Dictionary<UPC, int> stash, Collectible item)

        {

            int count = 0;

            UPC upc = getUPC(item);

            if (!stash.TryGetValue(upc, out count))

                initiateItem(stash, item);



            stash[upc] += 1;

        }



        /**

         * initiateItem - Initiates item in a given stash

         *

         * PARAMS

         *  stash - Linked List of items in the stash

         *  item  - Item to be added to the stash

         */

        private void initiateItem(Dictionary<UPC, int> stash, Collectible item)

        {

            UPC upc = getUPC(item);

            stash.Add(upc, 0);

        }



        /**

         * getUPC - Get's the UPC of a specific Collectible

         *

         * RETURN

         *  UPC - Type of item being worked with

         */

        public static UPC getUPC(Collectible item)

        {

            return item.GetType();

        }



        /**

         * initiateStash - Registers an owner inside of the Collections Manager

         *

         * PARAMS

         *  owner - The independent object owning a stash

         * 

         * RETURN

         *  Dictionary<UPC, int> - Stash for a given player

         */

        private Dictionary<UPC, int> initiateStash(Entity owner)

        {

            Dictionary<UPC, int> stash = new Dictionary<UPC, int>();

            ownerStash.Add(owner, stash);



            return stash;

        }



        /**

         * GetInstance - Grabs Collection Manager Instance

         *

         * GUARANTEED SINGLETON

         *

         * RETURN

         *  CollectionsManager - Instance of the Collections Manager

         */

        public static CollectionsManager GetInstance()

        {

            if (instance == null)

            {

                instance = new CollectionsManager();

            }



            return instance;

        }

    }

}

Friday, November 9, 2012

Level Design

We wanted to visualize our game in real life so we bought some legos and constructed a playground for the game.  It was a complete success because we were able to see how high players will be able to jump, climb, and do certain things with their new abilities.

In the programming world, I was able to play with the wall jumps so that the player can now jump between walls back and forth until they get to the end of the map.  I have also been planning some new objectives.  I feel it would be fun to have vehicles inside the game so that will be my next proposal.

Friday, November 2, 2012

Team Lead Improvement

This week I worked a lot with the main Team Lead to make sure that our roles were understood.  It seems that I have more of a organized contributor personality and the team lead has more of a micro-management mindset.  This is a hard situation to work together and have the same vision since context-communication is usually not closely looked at and roles are more expected.  I'm excited to learn more about how we can work together because my goal is to be well-rounded in every situation I'm put in and understanding the other person's point of view on the differences in our personality.  When we figure this out over this week, I feel the team will become a lot more effective because we complement one another's weaknesses and can more openly turn them into strengths.