public PlayerDataComponent() : base()
 {
     actionState         = PlayerActionState.Default;
     usableObject        = null;
     speedModifierObject = null;
     trashCount          = 0;
     closeWindows        = new HashSet <WindowComponent>();
     id = -1;
 }
Exemple #2
0
        public void Update(float dt, ISpeedModifier speedModifier)
        {
            float deltaTime = dt * speedModifier.GetSpeedMult(GeneratorId);

            totalTimer += deltaTime;

            if (UpdateWorkTimer(deltaTime))
            {
                return;
            }

            switch (State)
            {
            case AuditorState.MoveToLoad: {
                timer += deltaTime;
                if (timer >= MoveInterval)
                {
                    ChangeState(AuditorState.Loading);
                }
            }
            break;

            case AuditorState.Loading: {
                timer += deltaTime;
                if (timer >= LoadInterval)
                {
                    ChangeState(AuditorState.MoveToUnload);
                }
            }
            break;

            case AuditorState.MoveToUnload: {
                timer += deltaTime;
                if (timer >= MoveInterval)
                {
                    ChangeState(AuditorState.Unloading);
                }
            }
            break;

            case AuditorState.Unloading: {
                timer += deltaTime;
                if (timer >= UnloadInterval)
                {
                    ChangeState(AuditorState.MoveToLoad);
                }
            }
            break;

            case AuditorState.Completed: {
            }
            break;
            }
        }
Exemple #3
0
        public void Update(float dt, ISpeedModifier speedModifier)
        {
            //adInfo.Update(dt);
            float deltaTime = dt * speedModifier.GetSpeedMult(Id); //* adInfo.CurrentMultiplier;

            timer += deltaTime;

            AddOnSleep();

            switch (State)
            {
            case MechanicState.MoveToLoad: {
                if (timer >= MoveInterval)
                {
                    ChangeState(MechanicState.Loading);
                }
            }
            break;

            case MechanicState.Loading: {
                if (timer >= LoadInterval)
                {
                    ChangeState(MechanicState.MoveToUnload);
                }
            }
            break;

            case MechanicState.MoveToUnload: {
                if (timer >= MoveInterval)
                {
                    ChangeState(MechanicState.Unloading);
                }
            }
            break;

            case MechanicState.Unloading: {
                if (timer >= UnloadInterval)
                {
                    ChangeState(MechanicState.Completed);
                }
            }
            break;

            case MechanicState.Completed: {
                if (timer >= 1)
                {
                    ChangeState(MechanicState.MoveToLoad);
                }
            }
            break;
            }
        }
Exemple #4
0
        public void Update(float dt, ISpeedModifier speedMofifier)
        {
            //adInfo.Update(dt);
            float deltaTime = dt * speedMofifier.GetSpeedMult(GeneratorId); //* adInfo.CurrentMultiplier;

            timer += deltaTime;
            //UnityEngine.Debug.Log($"interval => {Interval}");
            AddOnSleep();
            switch (State)
            {
            case SecretaryState.MoveToLoad: {
                if (timer >= MoveInterval)
                {
                    ChangeState(SecretaryState.Loading);
                }
            }
            break;

            case SecretaryState.Loading: {
                if (timer >= LoadInterval)
                {
                    ChangeState(SecretaryState.MoveToUnload);
                }
            }
            break;

            case SecretaryState.MoveToUnload: {
                if (timer >= MoveInterval)
                {
                    ChangeState(SecretaryState.Unloading);
                }
            }
            break;

            case SecretaryState.Unloading: {
                if (timer >= UnloadInterval)
                {
                    ChangeState(SecretaryState.Completed);
                }
            }
            break;

            case SecretaryState.Completed: {
                if (timer >= 1)
                {
                    ChangeState(SecretaryState.MoveToLoad);
                }
            }
            break;
            }
        }
    private void RestoreSpeedMod(GameObject obj)
    {
        ISpeedModifier speedModObj = obj.GetComponent <ISpeedModifier>();

        if (speedModObj == null)
        {
            return;
        }

        // Skip if the speed mod object is not the same as the current
        if (_data.speedModifierObject != speedModObj)
        {
            return;
        }

        _data.speedModifierObject = null;
    }
    private void UpdateSpeedMod(GameObject obj)
    {
        ISpeedModifier speedModObj = obj.GetComponent <ISpeedModifier>();

        if (speedModObj == null)
        {
            return;
        }

        // Only update speed mod if the new speed mod is lesser than the current
        if (_data.speedModifierObject != null && _data.speedModifierObject.SpeedModifier < speedModObj.SpeedModifier)
        {
            return;
        }

        _data.speedModifierObject = speedModObj;
    }
        public void Update(float dt, ISpeedModifier speedModifier)
        {
            float deltaTime = dt * speedModifier.GetSpeedMult(GeneratorId);

            totalTimer += deltaTime;

            workTimer += deltaTime;
            if (workTimer >= 2.0f)
            {
                workTimer = Mathf.Clamp(workTimer, 0, WorkInterval + 1);
                int countToRepair = Mathf.FloorToInt(workTimer / 2.0f);
                if (countToRepair > 0)
                {
                    WorkInterval -= countToRepair * 2.0f;
                    workTimer    -= countToRepair * 2.0f;
                    GameEvents.TempMechanicRepairedTransportObservable.OnNext(new GameEvents.TempMechanicRepairInfo {
                        Mechanic    = this,
                        RepairCount = countToRepair
                    });
                    if (WorkInterval <= 0f)
                    {
                        ChangeState(TempMechanicState.Completed);
                        return;
                    }
                }
            }

            switch (State)
            {
            case TempMechanicState.MoveToLoad: {
                timer += deltaTime;
                if (timer >= MoveInterval)
                {
                    ChangeState(TempMechanicState.Loading);
                }
            }
            break;

            case TempMechanicState.Loading: {
                timer += deltaTime;
                if (timer >= LoadInterval)
                {
                    ChangeState(TempMechanicState.MoveToUnload);
                }
            }
            break;

            case TempMechanicState.MoveToUnload: {
                timer += deltaTime;
                if (timer >= MoveInterval)
                {
                    ChangeState(TempMechanicState.Unloading);
                }
            }
            break;

            case TempMechanicState.Unloading: {
                timer += deltaTime;
                if (timer >= UnloadInterval)
                {
                    timer = 0;
                    ChangeState(TempMechanicState.MoveToLoad);
                }
            }
            break;

            case TempMechanicState.Completed: {
            }
            break;
            }
        }