Пример #1
0
        public DemoPlayer(String path)
        {
            m_inputManager = new DefaultInputManager();
            m_inputManager.AddKeyboardListener(this);

            m_tickCmd = new DemoTickCmd();

            m_cmdLookup = new Dictionary <DemoCmdType, DemoCmd>();
            m_cmdLookup[DemoCmdType.Init]  = new DemoInitCmd();
            m_cmdLookup[DemoCmdType.Input] = new DemoInputCmd();
            m_cmdLookup[DemoCmdType.Tick]  = m_tickCmd;

            m_frameSkipLookup             = new Dictionary <KeyCode, int>();
            m_frameSkipLookup[KeyCode.D2] = 2;
            m_frameSkipLookup[KeyCode.D3] = 3;
            m_frameSkipLookup[KeyCode.D4] = 4;
            m_frameSkipLookup[KeyCode.D5] = 5;
            m_frameSkipLookup[KeyCode.D6] = 6;
            m_frameSkipLookup[KeyCode.D7] = 7;
            m_frameSkipLookup[KeyCode.D8] = 8;
            m_frameSkipLookup[KeyCode.D9] = 9;
            m_frameSkipLookup[KeyCode.D0] = 10;

            Read(path);
        }
Пример #2
0
        /// <summary>
        /// Create singleton instance.
        /// Auto sets up basic managers
        /// </summary>
        protected GameManager()
        {
            settings           = new PropertiesFiles(".gameprops");
            instance           = this;
            ObjectManager      = new DefaultObjectManager();
            InputManager       = new DefaultInputManager();
            InputSourceManager = new DefaultInputSourceManager();
            LogManager         = DefaultLogManager.Instance;


            HudManager = HudManager.Instance;
            ObjectManager.init();
            InputManager.init();
        }
Пример #3
0
        /// <summary>
        /// called just after creation.
        /// </summary>
        protected override void Initialize()
        {
            Controller            = this;
            WhiskeyGraphicsDevice = this.GraphicsDevice;

            InputSource = new EditorInputSource(this);
            if (Renderer == null)
            {
                Renderer = new EditorRenderManager();



                Content = new ContentManager(this.Services);
                Content.RootDirectory = "compile-media";
                //Content.RootDirectory = ProjectManager.Instance.ActiveProject.PathMedia;
                Resources = new EditorResourceManager();
                Resources.init(Content);
                Renderer.init(WhiskeyGraphicsDevice);
                //Resources = new DefaultResourceManager();
            }
            if (InputManager == null)
            {
                InputSourceManager = new DefaultInputSourceManager();
                InputManager       = new DefaultInputManager();
                InputManager.init(InputSourceManager);
            }



            //make sure GameManager exists
            //ensureGameManInitialized();



            timer             = Stopwatch.StartNew();
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 8);

            //create a new object manager, just for our control objects
            editorObjects = new DefaultObjectManager();
            editorObjects.init();

            //mark this control as the active one


            //construct the object controller, and make sure it resides in the correct object managers
            ObjectController        = new ObjectController(editorObjects);
            ObjectController.Sprite = new Sprite(Renderer, Resources, ObjectController.Sprite);



            //set the current level of the object controller
            if (ObjectController != null)
            {
                ObjectController.CurrentLevel = Level;
            }



            //////////

            setAsActive();
        }
Пример #4
0
    private void SwitchWeapon()
    {
        DefaultInputManager dim = new DefaultInputManager();

        switch (weaponsId)
        {
        case Weapons.None:
            Debug.Log("None");
            leftHand.GetComponent <HandController>().UnEquip();
            rightHand.GetComponent <HandController>().UnEquip();
            leftHand.GetComponent <HandController>().inputManager  = dim;
            rightHand.GetComponent <HandController>().inputManager = dim;
            if (firstTimeEquippingRunes)
            {
                Object     runes       = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Runes.prefab", typeof(GameObject));
                GameObject runesObject = (GameObject)Instantiate(runes, Vector3.zero, Quaternion.identity);
                //leftHand.GetComponent<HandController>().Equip(runesObject, "Wrist");

                RunesInputManager rim = new RunesInputManager();
                leftHand.GetComponent <HandController>().EquipRunes(runesObject);
                leftHand.GetComponent <HandController>().EquipRuneManager(rim);
                firstTimeEquippingRunes = false;
            }
            else
            {
                leftHand.GetComponent <HandController>().rim.Enable();
            }
            break;

        case Weapons.Bow:
            leftHand.GetComponent <HandController>().animator.SetBool("IsHolding", true);
            Debug.Log("Bow");
            leftHand.GetComponent <HandController>().UnEquip();
            rightHand.GetComponent <HandController>().UnEquip();

            Object     prefab    = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Bow.prefab", typeof(GameObject));
            GameObject newObject = (GameObject)Instantiate(prefab, Vector3.zero, Quaternion.identity);
            leftHand.GetComponent <HandController>().Equip(newObject, "BowHolder");
            BowInputManager bim = new BowInputManager();
            bim.bowData = newObject.GetComponentInChildren <BowData>();
            leftHand.GetComponent <HandController>().inputManager  = bim;
            rightHand.GetComponent <HandController>().inputManager = bim;
            break;

        case Weapons.Ice:
            leftHand.GetComponent <HandController>().UnEquip();
            rightHand.GetComponent <HandController>().UnEquip();

            //Object wand = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Wand.prefab", typeof(GameObject));
            //GameObject wandObject = (GameObject)Instantiate(wand, Vector3.zero, Quaternion.identity);
            //rightHand.GetComponent<HandController>().Equip(wandObject, "WandHolder");

            Object     frostBolt       = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/FrostBolt.prefab", typeof(GameObject));
            GameObject frostBoltObject = (GameObject)Instantiate(frostBolt, Vector3.zero, Quaternion.identity);

            SpellCaster wim = new SpellCaster();
            wim.castableObject = frostBoltObject;

            rightHand.GetComponent <HandController>().inputManager = wim;
            break;

        case Weapons.Sword:
            leftHand.GetComponent <HandController>().UnEquip();
            leftHand.GetComponent <HandController>().rim.Disable();
            rightHand.GetComponent <HandController>().UnEquip();

            Object     sword       = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Sword.prefab", typeof(GameObject));
            GameObject swordObject = (GameObject)Instantiate(sword, Vector3.zero, Quaternion.identity);

            Object     shield       = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Shield.prefab", typeof(GameObject));
            GameObject shieldObject = (GameObject)Instantiate(shield, Vector3.zero, Quaternion.identity);

            DefaultInputManager defIM = new DefaultInputManager();
            SwordInputManager   sim   = new SwordInputManager();
            rightHand.GetComponent <HandController>().inputManager = defIM;
            leftHand.GetComponent <HandController>().inputManager  = sim;
            rightHand.GetComponent <HandController>().Equip(swordObject, "WandHolder");
            leftHand.GetComponent <HandController>().Equip(shieldObject, "Wrist");
            break;

        case Weapons.Fire:
            leftHand.GetComponent <HandController>().UnEquip();
            rightHand.GetComponent <HandController>().UnEquip();

            //Object wand = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Wand.prefab", typeof(GameObject));
            //GameObject wandObject = (GameObject)Instantiate(wand, Vector3.zero, Quaternion.identity);
            //rightHand.GetComponent<HandController>().Equip(wandObject, "WandHolder");

            GameObject meteor = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Weapons/Meteor/Meteor.prefab", typeof(GameObject));
            LobCaster  lc     = new LobCaster();
            lc.lobbable = meteor;

            Debug.Log(meteor);
            leftHand.GetComponent <HandController>().inputManager  = dim;
            rightHand.GetComponent <HandController>().inputManager = lc;
            break;

        case Weapons.Lightning:
            leftHand.GetComponent <HandController>().UnEquip();
            rightHand.GetComponent <HandController>().UnEquip();

            GameObject bolt    = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Lightning.prefab", typeof(GameObject));
            GameObject boltObj = Instantiate(bolt);
            rightHand.GetComponent <HandController>().Equip(boltObj, "LightningSource");
            boltObj.transform.localPosition = Vector3.zero;
            boltObj.transform.localRotation = Quaternion.identity;
            LightningInputManager lim = new LightningInputManager();

            leftHand.GetComponent <HandController>().inputManager  = dim;
            rightHand.GetComponent <HandController>().inputManager = lim;
            break;

        case Weapons.Air:
            leftHand.GetComponent <HandController>().UnEquip();
            rightHand.GetComponent <HandController>().UnEquip();

            //Object wand = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Wand.prefab", typeof(GameObject));
            //GameObject wandObject = (GameObject)Instantiate(wand, Vector3.zero, Quaternion.identity);
            //rightHand.GetComponent<HandController>().Equip(wandObject, "WandHolder");

            GameObject airPrefab = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Prefabs/AirAttack.prefab", typeof(GameObject));
            LobCaster  airLc     = new LobCaster();
            airLc.lobbable = airPrefab;

            leftHand.GetComponent <HandController>().inputManager  = dim;
            rightHand.GetComponent <HandController>().inputManager = airLc;
            break;

        default:
            Debug.Log("Nonexistent Id");
            break;
        }
    }