Esempio n. 1
0
 public CameraShake(Environment environment, CameraAction.ShakeFx sf)
 {
     environment.ShakeCamera(
         sf.strength, sf.duration, sf.vibrato, sf.smoothness, sf.randomness,
         sf.useRandomInitialAngel, sf.rotation
         );
 }
Esempio n. 2
0
        private void TriggerOnGroundLandingEvents()
        {
            List <JumpAction.Event> events = jumpAction.FindEvents(
                JumpAction.Event.TriggerType.OnGroundLanding
                );

            for (int kIndex = 0; kIndex < events.Count; kIndex++)
            {
                JumpAction.Event            e  = events[kIndex];
                JumpAction.Event.ActionType at = e.ShowActionType();
                switch (at)
                {
                case JumpAction.Event.ActionType.CameraFx:
                    JumpAction.CameraFxEvent cfe    = (JumpAction.CameraFxEvent)e;
                    CameraAction.BaseFx      bf     = cfe.fx;
                    CameraAction.FxType      fxType = bf.ShowFxType();
                    switch (fxType)
                    {
                    case CameraAction.FxType.Shake:
                        CameraAction.ShakeFx sf = (CameraAction.ShakeFx)bf;
                        environment.ShakeCamera(
                            sf.strength, sf.duration, sf.vibrato, sf.smoothness, sf.randomness,
                            sf.useRandomInitialAngel, sf.rotation
                            );
                        break;

                    default:
                        throw new Exception("Missing logic to handle camera fx of type " + fxType);
                    }

                    break;

                case Event.ActionType.Vfx:
                    JumpAction.VfxEvent ve = (JumpAction.VfxEvent)e;
                    VfxAction.VfxType   vt = ve.fx.ShowVfxType();
                    switch (vt)
                    {
                    case VfxAction.VfxType.SpawnPrefab:
                        vfxLogic = new Vfxs.Vfx.SpawnPrefab(
                            5, (VfxAction.SpawnPrefabVfx)ve.fx,
                            new DefaultVfxGameObjectFactory(),
                            character,
                            SkillCastingSource.FromUserInput(),
                            environment.GetCamera(), environment, parentSkill
                            );
                        Timing.RunCoroutine(UpdateVfxLogic(vfxLogic));
                        break;
                    }
                    break;

                case Event.ActionType.Id:
                    parentSkill.TriggerEventWithId(((JumpAction.IdEvent)e).id);
                    break;

                default:
                    DLog.LogError("Missing logic to handle event of action type of " + at);
                    break;
                }
            }
        }
Esempio n. 3
0
        private void TriggerEvents()
        {
            List <Event> events = info.RagdollModifierConfig.ListAllEnabledEvents();

            for (int kIndex = 0; kIndex < events.Count; kIndex++)
            {
                Event e = events[kIndex];
                if (e.ShowTriggerType() != Event.TriggerType.OnGroundLanding)
                {
                    continue;
                }
                if (processedEvents.Contains(e))
                {
                    continue;
                }

                processedEvents.Add(e);
                Event.ActionType at = e.ShowActionType();
                switch (at)
                {
                case Event.ActionType.CameraFx:
                    JumpAction.CameraFxEvent cfe = (JumpAction.CameraFxEvent)e;
                    CameraAction.FxType      ft  = cfe.fx.ShowFxType();
                    switch (ft)
                    {
                    case CameraAction.FxType.Shake:
                        CameraAction.ShakeFx sf = (CameraAction.ShakeFx)cfe.fx;
                        ProCamera2DShake     proCamera2DShake;
                        proCamera2DShake = camera.GetComponent <ProCamera2DShake>();
                        if (proCamera2DShake == null)
                        {
                            proCamera2DShake = camera.gameObject.AddComponent <ProCamera2DShake>();
                        }

                        proCamera2DShake.Strength              = sf.strength;
                        proCamera2DShake.Duration              = sf.duration;
                        proCamera2DShake.Vibrato               = sf.vibrato;
                        proCamera2DShake.Smoothness            = sf.smoothness;
                        proCamera2DShake.Randomness            = sf.randomness;
                        proCamera2DShake.UseRandomInitialAngle = sf.useRandomInitialAngel;
                        proCamera2DShake.Rotation              = sf.rotation;
                        proCamera2DShake.Shake();
                        break;
                    }
                    break;

                case Event.ActionType.Vfx:
                    JumpAction.VfxEvent ve = (JumpAction.VfxEvent)e;
                    VfxAction.VfxType   vt = ve.fx.ShowVfxType();
                    switch (vt)
                    {
                    case VfxAction.VfxType.SpawnPrefab:
                        vfxLogic = new Vfxs.Vfx.SpawnPrefab(
                            10, (VfxAction.SpawnPrefabVfx)ve.fx,
                            new DefaultVfxGameObjectFactory(),
                            targetEntity.GetComponent <SkillComponent>().Character,
                            SkillCastingSource.FromUserInput(),
                            environment.GetCamera(), environment, null
                            );
                        break;
                    }
                    break;
                }
            }
        }
Esempio n. 4
0
        public Loopable Produce(Character caster, Skill skill, SkillId skillId, BaseEvent baseEvent,
                                SkillCastingSource skillCastingSource, TemplateArgs args)
        {
            BaseAction ba         = baseEvent.ShowAction();
            ActionType actionType = ba.ShowActionType();
            Loopable   loopable   = null;

            switch (actionType)
            {
            case ActionType.Camera:
                CameraAction        ca     = (CameraAction)ba;
                CameraAction.BaseFx bf     = ca.fx;
                CameraAction.FxType fxType = bf.ShowFxType();
                switch (fxType)
                {
                case CameraAction.FxType.Shake:
                    CameraAction.ShakeFx sf = (CameraAction.ShakeFx)bf;
                    loopable = new CameraShake(environment, sf);
                    break;

                case CameraAction.FxType.Fade:
                    loopable = new CameraFade(environment, baseEvent);
                    break;

                case CameraAction.FxType.CinematicZoomToSelf:
                    loopable = new CameraCinematicZoomToSelf(environment, baseEvent, caster);
                    break;

                case CameraAction.FxType.SlowMotion:
                    loopable = new CameraSlowMotion(environment, baseEvent);
                    break;

                case CameraAction.FxType.AddTarget:
                    loopable = new CameraAddTarget(environment, baseEvent, caster);
                    break;

                default:
                    throw new Exception("Missing logic to handle camera fx of type " + fxType);
                }
                break;

            case ActionType.Dash:
                Dash dash = new Dash(baseEvent, caster, skill.IgnoreMinSpeedOnAirForDashes(), skill, environment);
                loopable = dash;
                break;

            case ActionType.Jump:
                bool jumpOverDistance = true;
                if (args != null)
                {
                    bool found;
                    jumpOverDistance = args.TryGetEntry <bool>(TemplateArgsName.JumpSkill_JumpOverDistance, out found);
                    if (!found)
                    {
                        jumpOverDistance = true;
                    }
                }
                Jump jump = new Jump(baseEvent, caster, skill, environment, jumpOverDistance);
                loopable = jump;
                break;

            case ActionType.Vfx:
                Vfxs.Vfx vfx = new Vfxs.Vfx(
                    baseEvent, environment, caster, skillCastingSource, skill, args
                    );
                loopable = vfx;
                break;

            case ActionType.Modifier:
                ModifierAction     ma       = (ModifierAction)ba;
                BaseModifierConfig bmc      = ma.modifierConfig;
                ModifierInfo       mi       = modifierInfoFactory.CreateFrom(skill, bmc, environment);
                EntityReference    er       = caster.GameObject().GetComponent <EntityReference>();
                Modifier           modifier = DamageSystem.Instance.CreateModifier(
                    mi, er.Entity, er.Entity, caster.Position(),
                    caster.Position(), skill, skillId, 0
                    );
                if (modifier != null)
                {
                    caster.AddModifier(modifier);
                }
                loopable = new ModifierLoopable(modifier);
                break;

            case ActionType.Animation:
                loopable = new AnimationPlayback(baseEvent, caster);
                break;

            case ActionType.Teleport:
                TeleportAction          ta   = (TeleportAction)baseEvent.action;
                TeleportAction.ModeName mode = ta.mode.ShowModeName();
                switch (mode)
                {
                case TeleportAction.ModeName.PredefinedPositionOnMap:
                    new Teleport(baseEvent, caster, environment);
                    loopable = new ImmediatelyFinishedLoopable();
                    break;

                case TeleportAction.ModeName.KeepDistance:
                    TeleportAction.KeepDistanceMode kdm = (TeleportAction.KeepDistanceMode)ta.mode;
                    loopable = new TeleportKeepDistanceLogic(kdm, skill, environment, caster);
                    break;

                case TeleportAction.ModeName.AroundTarget:
                    TeleportAction.AroundTargetMode atm = (TeleportAction.AroundTargetMode)ta.mode;
                    loopable = new TeleportAroundTargetLogic(atm, caster, environment, skill);
                    break;

                case TeleportAction.ModeName.AroundTeamMate:
                    TeleportAction.AroundTeamMateMode atmm = (TeleportAction.AroundTeamMateMode)ta.mode;
                    loopable = new TeleportAroundTeamMate(atmm, caster, environment, skill);
                    break;

                default:
                    throw new Exception("Cannot create teleport of type " + mode);
                }
                break;

            case ActionType.FacingDirection:
                loopable = new FacingDirection(baseEvent, caster, environment);
                break;

            case ActionType.DashTowardTarget:
                DashTowardTarget dtt = new DashTowardTarget(baseEvent, caster, environment);
                loopable = dtt;
                break;

            case ActionType.JumpTowardTarget:
                loopable = new JumpTowardTarget(baseEvent, caster, environment);
                break;

            case ActionType.SpawnCharacter:
                SpawnCharacterAction sca = (SpawnCharacterAction)ba;
                loopable = new SpawnCharacter(sca, entitySpawner, caster, args, environment, skillId, hamc);
                break;

            case ActionType.Rotation:
                loopable = new Rotation(baseEvent, caster, environment);
                break;

            case ActionType.Timer:
                loopable = new Timer(baseEvent, skill);
                break;

            case ActionType.Sound:
                loopable = new AudioClipPlayback(baseEvent, environment);
                break;

            case ActionType.PassiveSkillOnOff:
                loopable = new PassiveSkillOnOff(baseEvent, caster);
                break;

            case ActionType.DistanceTracker:
                loopable = new DistanceTracker(baseEvent, skill, caster);
                break;

            case ActionType.SelfDamageDealing:
                loopable = new SelfDamageDealing(baseEvent, caster, skill, skillId);
                break;

            case ActionType.SwitchPhase:
                loopable = new SwitchPhase(skill);
                break;

            case ActionType.Movable:
                Entity        casterEntity  = caster.GameObject().GetComponent <EntityReference>().Entity;
                UserInput     userInput     = casterEntity.GetComponent <HeroStateMachineComponent>().UserInput;
                MovableAction movableAction = (MovableAction)ba;
                loopable = new Movable(movableAction, skill, caster.FacingDirection(), userInput, caster);
                break;

            case ActionType.Input:
                casterEntity = caster.GameObject().GetComponent <EntityReference>().Entity;
                userInput    = casterEntity.GetComponent <HeroStateMachineComponent>().UserInput;
                InputAction ia = (InputAction)ba;
                loopable = new InputSimulation(ia, (DefaultUserInput)userInput);
                break;

#if UNITY_EDITOR
            case ActionType.Macro:
                loopable = new Macro(baseEvent, caster);
                break;
#endif
            default:
                DLog.Log("Missing logic to handle action of type " + actionType);
                break;
            }

            return(loopable);
        }