示例#1
0
    //##############################################################################################
    // Setup the player, and collect the different components that will get used.
    //##############################################################################################
    void Start()
    {
        player       = this;
        respawnState = RespawnState.Alive;

        // Hide the cursor and lock it to screen
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;

        // Try to target 60
        Application.targetFrameRate = 60;

        movementEnabled = true;
        lookingEnabled  = true;

        gun       = GetComponent <GunComponent>();
        character = GetComponent <CharacterController>();
        damage    = GetComponent <DamageableComponent>();

        damage.RegisterOnDamagedDelegate(OnDamaged);
        damage.RegisterOnKilledDelegate(OnKilled);

        respawnTimer          = new Timer(respawnTime);
        shakeDecayTimer       = new Timer(SHAKE_DECAY_TIME);
        safeTimer             = new Timer(SAFE_TIME);
        recoilDecayTimer      = new Timer();
        jumpTimer             = new Timer(jumpTime);
        sideJumpCooldownTimer = new Timer(SIDE_JUMP_COOLDOWN_TIME);
    }
        public DaggerfallGame(string path)
        {
            this.path = path;

            manager = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth       = StartFullScreen ? 1 : GraphicsDeviceManager.DefaultBackBufferWidth,
                PreferredBackBufferHeight      = StartFullScreen ? 1 : GraphicsDeviceManager.DefaultBackBufferHeight,
                PreferMultiSampling            = true,
                SynchronizeWithVerticalRetrace = true,
                IsFullScreen = StartFullScreen,
            };

            Components.Add(Viewer = new FirstPersonPlayerComponent(this)
            {
                MouseEnabled          = true,
                FarPlaneDistance      = 1 << 20,
                    NearPlaneDistance = 1 << 8,
                    Enabled           = true,
                    WalkSpeed         = 1 << 10,
                    FlyUpDirection    = new Vector3(0, 1 << 10, 0),
            });

            new ModelBrowserTool(this);
            new BlockBrowserTool(this);
            new TextureBrowserTool(this);
            Tools[0].Enabled = Tools[0].Visible = true;
        }
示例#3
0
    //##############################################################################################
    // Check for required data, then setup the gun
    //##############################################################################################
    protected void Start()
    {
        if (muzzleTransform == null)
        {
            Logger.Error("Muzzle Actor on " + gameObject.name + "'s GunComponent cannot be null");
        }

        gunTimer    = new Timer(currentGunData.coolDown);
        reloadTimer = new Timer(currentGunData.reloadTime);

        player = GetComponent <FirstPersonPlayerComponent>();

        if (currentGunData.usePooledBullets)
        {
            if (!PooledGameObjectManager.HasPoolForIdentifier(currentGunData.poolIdentifier))
            {
                PooledGameObjectManager.SetupPool(currentGunData.poolIdentifier, currentGunData.poolSize, currentGunData.bulletPrefab);
            }
        }
    }