예제 #1
0
 public void Reload(ReloadState reloadState)
 {
     Log.log("Reload {0}", reloadState.ToString());
     if (reloadState == ReloadState.None)
     {
         return;
     }
     if (reloadState == ReloadState.Managed)
     {
         Reloading = true;
         // TODO:Editor Reload ? Hooks?
         //MainForm.Instance.CloseSaveConfirmed = true;
         //MainForm.Instance.Close();
         Binding.UnloadDll();
         return;
     }
     if (reloadState == ReloadState.Native)
     {
         Reloading = true;
         // TODO:Editor Reload Native ? Hooks?
         //MainForm.Instance.CloseSaveConfirmed = true;
         //MainForm.Instance.Close();
         Binding.FCE_Editor_Destroy();
         Binding.UnloadDll();
         Binding.UnloadIGEDll();
         File.Copy(BinDir + "output\\" + Binding.gameDll, BinDir + Binding.gameDll, true);
         string text = Path.ChangeExtension(Binding.gameDll, ".pdb");
         File.Copy(BinDir + "output\\" + text, BinDir + text, true);
         Binding.LoadIGEDll();
         Binding.LoadDll();
         Binding.FCE_Editor_Create(true);
         Binding.UnloadDll();
     }
 }
    public override void StartFSM()
    {
        _idleState   = new IdleState <states>(this, flags, _treeStartPoint);
        _followState = new FollowState <states>(this, myLeader, flags, _treeStartPoint, stopDist);
        _attackState = new AttackState <states>(this, flags, _treeStartPoint);
        _escapeState = new EscapeState <states>(this, flags, _treeStartPoint);
        _reloadState = new ReloadState <states>(this, flags, _treeStartPoint);

        fsm = new FSM <states>(_idleState);

        _idleState.AddTransition(states.Follow, _followState);
        _idleState.AddTransition(states.Attack, _attackState);
        _idleState.AddTransition(states.Escape, _escapeState);
        _idleState.AddTransition(states.Reload, _reloadState);

        _followState.AddTransition(states.Idle, _idleState);
        _followState.AddTransition(states.Attack, _attackState);
        _followState.AddTransition(states.Escape, _escapeState);
        _followState.AddTransition(states.Reload, _reloadState);

        _attackState.AddTransition(states.Idle, _idleState);
        _attackState.AddTransition(states.Follow, _followState);
        _attackState.AddTransition(states.Escape, _escapeState);
        _attackState.AddTransition(states.Reload, _reloadState);

        _reloadState.AddTransition(states.Idle, _idleState);
        _reloadState.AddTransition(states.Attack, _attackState);
        _reloadState.AddTransition(states.Follow, _followState);
        _reloadState.AddTransition(states.Escape, _escapeState);

        _escapeState.AddTransition(states.Idle, _idleState);
        _escapeState.AddTransition(states.Follow, _followState);

        fsm.SetState(_idleState);
    }
예제 #3
0
 private void Reload_PlayEnd()
 {
     WeaponObject.animation.Stop();
     WeaponObject.animation.Play("reloadEmptyEnd");
     CurrentReload = ReloadState.ReloadEnd;
     CanReload     = true;
     NeedsToReload = false;
 }
예제 #4
0
    private void Awake()
    {
        aggroState  = new AggroState(this);
        battleState = new BattleState(this);
        fightState  = new FightState(this);
        reloadState = new ReloadState(this);

        currentState = battleState;
    }
    public override void StartFSM()
    {
        _leadState   = new LeadState <states>(this, flags, leadStopDistance, _treeStartPoint);
        _attackState = new AttackState <states>(this, flags, _treeStartPoint);
        _buffState   = new BuffState <states>(this, flags, _treeStartPoint);
        _escapeState = new EscapeState <states>(this, flags, _treeStartPoint);
        _idleState   = new IdleState <states>(this, flags, _treeStartPoint);
        _reloadState = new ReloadState <states>(this, flags, _treeStartPoint);

        fsm = new FSM <states>(_idleState);

        _idleState.AddTransition(states.Attack, _attackState);
        _idleState.AddTransition(states.Buff, _buffState);
        _idleState.AddTransition(states.Lead, _leadState);
        _idleState.AddTransition(states.Escape, _escapeState);
        _idleState.AddTransition(states.Reload, _reloadState);

        _leadState.AddTransition(states.Attack, _attackState);
        _leadState.AddTransition(states.Buff, _buffState);
        _leadState.AddTransition(states.Escape, _escapeState);
        _leadState.AddTransition(states.Idle, _idleState);
        _leadState.AddTransition(states.Reload, _reloadState);

        _attackState.AddTransition(states.Lead, _leadState);
        _attackState.AddTransition(states.Buff, _buffState);
        _attackState.AddTransition(states.Escape, _escapeState);
        _attackState.AddTransition(states.Idle, _idleState);
        _attackState.AddTransition(states.Reload, _reloadState);

        _reloadState.AddTransition(states.Idle, _idleState);
        _reloadState.AddTransition(states.Attack, _attackState);
        _reloadState.AddTransition(states.Buff, _buffState);
        _reloadState.AddTransition(states.Lead, _leadState);
        _reloadState.AddTransition(states.Escape, _escapeState);

        _buffState.AddTransition(states.Lead, _leadState);
        _buffState.AddTransition(states.Attack, _attackState);
        _buffState.AddTransition(states.Escape, _escapeState);
        _buffState.AddTransition(states.Idle, _idleState);
        _buffState.AddTransition(states.Reload, _reloadState);

        _escapeState.AddTransition(states.Idle, _idleState);
        _escapeState.AddTransition(states.Lead, _leadState);

        fsm.SetState(_idleState);
    }
예제 #6
0
        private IEnumerator Reload(float time)
        {
            while (reloadState == ReloadState.RELOAD)
            {
                time -= reloadTime / 10f;
                yield return(new WaitForSeconds(reloadTime / 10f));

                EventMessenger.TriggerEvent(GameEvents.CHARGE);
                percentReload = Mathf.RoundToInt(100f - time * 100f / reloadTime);
                if (percentReload >= 100)
                {
                    AudioSource.PlayClipAtPoint(fireReady, Camera.main.transform.position);
                    yield return(new WaitForSeconds(0.2f));

                    reloadState = ReloadState.READY;
                }
                yield return(null);
            }
        }
예제 #7
0
    private void Reload_End()
    {
        CurrentReload = ReloadState.None;

        StartIdling();

        if (AmmoTotal >= (MaxAmmoPerClip - AmmoInClip))
        {
            AmmoTotal -= (MaxAmmoPerClip - AmmoInClip);
            AmmoInClip = MaxAmmoPerClip;
        }
        else
        {
            AmmoInClip = (int)AmmoTotal;
            AmmoTotal  = 0;
        }

        CanReload     = true;
        NeedsToReload = false;
    }
예제 #8
0
    public void Reload()
    {
        if (CurrentReload == ReloadState.None && CanReload == true)
        {
            CanReload = false;

            if (AmmoInBarrel > 0)
            {
                int r = Random.Range(0, ShortReloadSounds.Length);
                CurrentReload = ReloadState.ReloadFull;
                Player._AudioSource.PlayOneShot(ShortReloadSounds[r]);
                WeaponObject.animation.Play("reload");
            }
            else
            {
                int r = Random.Range(0, LongReloadSounds.Length);
                CurrentReload = ReloadState.ReloadStart;
                Player._AudioSource.PlayOneShot(LongReloadSounds[r]);
                WeaponObject.animation.Play("reloadEmptyStart");
                WeaponObject.animation.PlayQueued("reloadEmptyEnd");
            }
        }
    }
예제 #9
0
        private bool AllowReload(Document newDocument, ref object state)
        {
            // Allow non-dirty files to reload automatically
            if (!IsDirty)
            {
                return(true);
            }

            // Don't reload removed files
            if (!File.Exists(FullPath))
            {
                return(false);
            }

            var reloadState = state as ReloadState;

            if (reloadState == null)
            {
                state = reloadState = new ReloadState();
            }

            var reloadMode = reloadState.AutoReloadDirty;

            var reloadAllowed = true;

            // User pressed YesToAll or NoToAll before
            // Let's return same value
            if (reloadMode.HasValue)
            {
                reloadAllowed = reloadMode.Value;
            }
            else
            {
                // Ask user
                var buttons = DialogHelper.CreateButtons(new[]
                {
                    "Yes", "Yes to all", "No", "No to all"
                });
                var message = string.Format(
                    Tr._p("Message", "{0}\r\n\r\nThis file has been changed externally and has unsaved changes inside the editor.\r\nDo you want to reload it and lose your changes?"),
                    newDocument.FilePath);
                var dialogResult = ServiceProvider.Get <IDialogService>().BlockingMessageBox(message, buttons, MessageBoxImage.Question);

                switch (dialogResult)
                {
                case 1:
                    reloadAllowed = true;
                    break;

                case 2:
                    reloadState.AutoReloadDirty = reloadAllowed = true;
                    break;

                case 3:
                    reloadAllowed = false;
                    break;

                case 0:
                case 4:
                    reloadState.AutoReloadDirty = reloadAllowed = false;
                    break;
                }
            }

            // Mark the document as dirty since we didn't update to external changed
            if (!reloadAllowed)
            {
                hasExternalChanges = true;
                UpdateDirtiness();
            }

            return(reloadAllowed);
        }
예제 #10
0
 public void Reload(ReloadState reloadState)
 {
     Log.log("Reload {0}", reloadState.ToString());
     if (reloadState == ReloadState.None)
     {
         return;
     }
     if (reloadState == ReloadState.Managed)
     {
         Reloading = true;
         // TODO:Editor Reload ? Hooks?
         //MainForm.Instance.CloseSaveConfirmed = true;
         //MainForm.Instance.Close();
         Binding.UnloadDll();
         return;
     }
     if (reloadState == ReloadState.Native)
     {
         Reloading = true;
         // TODO:Editor Reload Native ? Hooks?
         //MainForm.Instance.CloseSaveConfirmed = true;
         //MainForm.Instance.Close();
         Binding.FCE_Editor_Destroy();
         Binding.UnloadDll();
         Binding.UnloadIGEDll();
         File.Copy(BinDir + "output\\" + Binding.gameDll, BinDir + Binding.gameDll, true);
         string text = Path.ChangeExtension(Binding.gameDll, ".pdb");
         File.Copy(BinDir + "output\\" + text, BinDir + text, true);
         Binding.LoadIGEDll();
         Binding.LoadDll();
         Binding.FCE_Editor_Create(true);
         Binding.UnloadDll();
     }
 }
예제 #11
0
    public ControlSpMovement(ref IMovementAndMeleeCombatLogic input, ref IMove characterController
                             , ref Animator animator, ref IRangedCombatLogic rangedLogic, ref IInvertoryLogic invertoryLogic, ref ISpCameraFollow camera)
    {
        this.rangedInput = rangedLogic;
        this.rangedInput.InputChanged += RangedInput_InputChanged;
        this.invertoryInput            = invertoryLogic;
        this.spCamera = camera;

        // Movement FSM setup
        this.movementAndMeleeControl = input;
        this.fSMSpMovement           = new FSMachineSpacemarineMove(EMovementID.Walking, ref this.movementAndMeleeControl, true);

        WalkState  walkState  = new WalkState(true, 2.0f, ref characterController, ref this.movementAndMeleeControl, EMovementID.Walking, ref animator);
        RunState   runState   = new RunState(false, 5.0f, ref characterController, ref this.movementAndMeleeControl, EMovementID.Running, ref animator);
        SmashState smashState = new SmashState(false, 6.0f, 1.25f, ref characterController, ref this.movementAndMeleeControl, EMovementID.Smashing, ref animator);
        FallState  fallState  = new FallState(2.0f, -Physics.gravity.y * Vector3.down, true, ref characterController, ref this.movementAndMeleeControl, EMovementID.Falling, ref animator);
        LandState  landState  = new LandState(0.75f, false, ref input, ref characterController, EMovementID.Landing);

        this.fSMSpMovement.AddState(walkState);
        this.fSMSpMovement.AddState(runState);
        this.fSMSpMovement.AddState(smashState);
        this.fSMSpMovement.AddState(fallState);
        this.fSMSpMovement.AddState(landState);
        this.fSMSpMovement.SetDefaultState(walkState);

        this.fSMSpMovement.StateChanged += FSMSpMovement_StateChanged;

        // Melee FSM machine setup
        AttackState attackState = new AttackState(false, EMeleeAttackID.Attacking, ref this.movementAndMeleeControl, ref invertoryLogic, ref animator);
        MeleeIdle   meleeIdle   = new MeleeIdle(true, EMeleeAttackID.Idle, ref this.movementAndMeleeControl);

        this.fSMSpCombat = new FSMCombatSpacemarine(true, EMeleeAttackID.Idle, ref this.movementAndMeleeControl, ref invertoryLogic);

        this.fSMSpCombat.AddState(attackState);
        this.fSMSpCombat.AddState(meleeIdle);
        this.fSMSpCombat.SetDefaultState(meleeIdle);

        //Ranged FSM setup
        IHoldWeapon       holdWeaponInfo = new HoldPistol(5.0f);
        IRangedState      holdState      = new HoldState(true, ref rangedLogic, ERangedAttackID.Hold, ref holdWeaponInfo, ref animator, ref invertoryInput);
        IRangedShootState shootState     = new ShootState(true, ERangedAttackID.Shoot, ref rangedLogic, ref animator, ref invertoryLogic);
        IRangedState      reloadState    = new ReloadState(true, ref rangedLogic, ERangedAttackID.Reload, ref invertoryLogic, ref animator);
        IRangedState      laydownState   = new LaydownState(true, ref rangedLogic, ERangedAttackID.LayDown, ref invertoryLogic);

        this.fSMSpRangedCombat = new FSMRangedSpacemarine(true, ERangedAttackID.LayDown, ref rangedLogic, ref invertoryLogic);

        this.fSMSpRangedCombat.AddState(holdState);
        this.fSMSpRangedCombat.AddState(reloadState);
        this.fSMSpRangedCombat.AddState(shootState);
        this.fSMSpRangedCombat.AddState(laydownState);
        this.fSMSpRangedCombat.SetDefaultState(laydownState);

        this.fSMSpRangedCombat.StateChanged += FSMSpRangedCombat_StateChanged;

        // Invertory Setup
        InvertoryIdle   invertoryIdleState   = new InvertoryIdle(true, ref invertoryLogic);
        InvertorySwitch invertorySwitchState = new InvertorySwitch(true, ref invertoryLogic, ref animator);

        this.fSMInvertory = new FSMInvertory(EInvertoryStateID.None, ref invertoryLogic);

        this.fSMInvertory.AddState(invertoryIdleState);
        this.fSMInvertory.AddState(invertorySwitchState);
        this.fSMInvertory.SetDefaultState(invertoryIdleState);

        this.fSMInvertory.StateChanged += FSMInvertory_StateChanged;

        if (invertoryLogic.HasInputModel)
        {
            this.spCamera.ObjectRotator.CanRotate = !invertoryLogic.InputInfo.CurrentWeapons.IsMeleeEquipment;
            this.spCamera.IsMeleeViewEnabled      = !invertoryLogic.InputInfo.CurrentWeapons.IsMeleeEquipment;
        }
        else
        {
            this.spCamera.IsMeleeViewEnabled = false;
        }
    }
예제 #12
0
 private void Reload_PlayEnd()
 {
     WeaponObject.animation.Stop();
     WeaponObject.animation.Play("reloadEmptyEnd");
     CurrentReload = ReloadState.ReloadEnd;
     CanReload = true;
     NeedsToReload = false;
 }
예제 #13
0
    private void Reload_End()
    {
        CurrentReload = ReloadState.None;

        StartIdling();

        if (AmmoTotal >= (MaxAmmoPerClip - AmmoInClip))
        {
            AmmoTotal -= (MaxAmmoPerClip - AmmoInClip);
            AmmoInClip = MaxAmmoPerClip;
        }
        else
        {
            AmmoInClip = (int)AmmoTotal;
            AmmoTotal = 0;
        }

        CanReload = true;
        NeedsToReload = false;
    }
예제 #14
0
    public void Reload()
    {
        if (CurrentReload == ReloadState.None && CanReload == true)
        {
            CanReload = false;

            if (AmmoInBarrel > 0)
            {
                int r = Random.Range(0, ShortReloadSounds.Length);
                CurrentReload = ReloadState.ReloadFull;
                Player._AudioSource.PlayOneShot(ShortReloadSounds[r]);
                WeaponObject.animation.Play("reload");

            }
            else
            {
                int r = Random.Range(0, LongReloadSounds.Length);
                CurrentReload = ReloadState.ReloadStart;
                Player._AudioSource.PlayOneShot(LongReloadSounds[r]);
                WeaponObject.animation.Play("reloadEmptyStart");
                WeaponObject.animation.PlayQueued("reloadEmptyEnd");
            }

        }
    }
예제 #15
0
 private void Reload()
 {
     StopAllCoroutines();
     reloadState = ReloadState.RELOAD;
     StartCoroutine(Reload(reloadTime));
 }