private AlarmTriggeringAction createAlarmTriggerAction(MethodAction methodAction) 
     {
    AlarmTriggeringAction alarmAction = new AlarmTriggeringAction();
    alarmAction.yellow2red = true;
    alarmAction.action=methodAction;
    return alarmAction;
 }
Exemplo n.º 2
0
        static void MarkMethod(LinkContext context, MethodDefinition method, MethodAction action, RootVisibility rootVisibility)
        {
            bool markMethod;

            switch (rootVisibility)
            {
            default:
                markMethod = true;
                break;

            case RootVisibility.PublicAndFamily:
                markMethod = method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly;
                break;

            case RootVisibility.PublicAndFamilyAndAssembly:
                markMethod = method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly || method.IsAssembly || method.IsFamilyAndAssembly;
                break;
            }

            if (markMethod)
            {
                context.Annotations.Mark(method);
                context.Annotations.SetAction(method, action);
            }
        }
        public static ServiceProvider BuildServiceProvider()
        {
            var services = new ServiceCollection();

            services.AddDbContext <ScenarioContext>();
            services.AddTransient(typeof(IGenericRepository <>), typeof(GenericRepository <>));
            services.AddTransient <IScenarioRepository, ScenarioRepository>();
            services.AddTransient <IFolderRepository, FolderRepository>();

            services.AddSingleton <IReflectedCollection, ReflectedCollection>();
            services.AddTransient <IVariableAction, VariableAction>();
            services.AddTransient <IMethodAction, MethodAction>();
            services.AddTransient <IAssertAction, AssertAction>();
            services.AddTransient <IExecutor, Executor>(serviceProvider =>
            {
                var reflectedCollection = serviceProvider.GetService <IReflectedCollection>();
                var variableAction      = serviceProvider.GetService <IVariableAction>();
                var methodAction        = new MethodAction(variableAction, reflectedCollection);
                var assertAction        = new AssertAction(variableAction);

                return(new Executor(variableAction, methodAction, assertAction));
            });

            services.AddTransient <IScenarioCreatorService, ScenarioCreatorService>();
            services.AddTransient <IScenarioExecutorService, ScenarioExecutorService>();
            services.AddTransient <IScenarioListService, ScenarioListService>();

            return(services.BuildServiceProvider());
        }
 private MethodAction createPowerOnAction() {
    MethodAction action = new MethodAction();
    action.name="PowerOnVM_Task";
    MethodActionArgument argument = new MethodActionArgument();
    argument.value=null;
    action.argument= new MethodActionArgument[] { argument };
    return action;
 }
        private AlarmTriggeringAction createAlarmTriggerAction(MethodAction methodAction)
        {
            AlarmTriggeringAction alarmAction = new AlarmTriggeringAction();

            alarmAction.yellow2red = true;
            alarmAction.action     = methodAction;
            return(alarmAction);
        }
Exemplo n.º 6
0
        public Method AddMethod(MethodDefinition method, MethodAction action)
        {
            var parent = GetType(method.DeclaringType, true);
            var entry  = new Method(parent, method, action);

            parent.Methods.Add(entry);
            return(entry);
        }
        private MethodAction createPowerOnAction()
        {
            MethodAction action = new MethodAction();

            action.name = "PowerOnVM_Task";
            MethodActionArgument argument = new MethodActionArgument();

            argument.value  = null;
            action.argument = new MethodActionArgument[] { argument };
            return(action);
        }
 /**
  * Create method action to power off a vm
  * 
  * @return the action to run when the schedule runs
  */
 private Vim25Api.Action createTaskAction() {
    MethodAction action = new MethodAction();
    
    // Method Name is the WSDL name of the 
    // ManagedObject's method that is to be run, 
    // in this Case, the powerOff method of the VM
    action.name = "PowerOffVM_Task";
    
    // There are no arguments to this method
    // so we pass in an empty MethodActionArgument
    action.argument= new MethodActionArgument[] { };
    return action;
 }
        /**
         * Create method action to power off a vm
         *
         * @return the action to run when the schedule runs
         */
        private Vim25Api.Action createTaskAction()
        {
            MethodAction action = new MethodAction();

            // Method Name is the WSDL name of the
            // ManagedObject's method that is to be run,
            // in this Case, the powerOff method of the VM
            action.name = "PowerOffVM_Task";

            // There are no arguments to this method
            // so we pass in an empty MethodActionArgument
            action.argument = new MethodActionArgument[] { };
            return(action);
        }
Exemplo n.º 10
0
        static void MarkMethod(LinkContext context, MethodDefinition method, MethodAction action, RootVisibility rootVisibility)
        {
            bool markMethod = rootVisibility switch {
                RootVisibility.PublicAndFamily => method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly,
                RootVisibility.PublicAndFamilyAndAssembly => method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly || method.IsAssembly || method.IsFamilyAndAssembly,
                _ => true
            };

            if (markMethod)
            {
                context.Annotations.Mark(method, new DependencyInfo(DependencyKind.RootAssembly, method.Module.Assembly));
                context.Annotations.SetAction(method, action);
            }
        }
Exemplo n.º 11
0
        public static void Main(String[] args)
        {
            VMPowerStateAlarm obj = new VMPowerStateAlarm();

            cb = AppUtil.AppUtil.initialize("VMPowerStateAlarm"
                                            , VMPowerStateAlarm.constructOptions()
                                            , args);
            cb.connect();
            String apitype = cb.getConnection()._sic.about.apiType;

            if (apitype != "HostAgent")
            {
                obj.getVmMor(cb.get_option("vmname"));
                if (obj._virtualMachine != null)
                {
                    ObjectContent[] oc = cb.getServiceUtil().GetObjectProperties
                                             (cb.getConnection().PropCol, obj._virtualMachine,
                                             new String[] { "config" });
                    VirtualMachineConfigInfo vmConfig =
                        (VirtualMachineConfigInfo)oc[0].propSet[0].val;
                    if (!vmConfig.template)
                    {
                        StateAlarmExpression expression   = obj.createStateAlarmExpression();
                        MethodAction         methodAction = obj.createPowerOnAction();
                        AlarmAction          alarmAction
                            = (AlarmAction)obj.createAlarmTriggerAction(methodAction);
                        AlarmSpec alarmSpec = obj.createAlarmSpec(alarmAction, expression);
                        obj.createAlarm(alarmSpec);
                    }
                    else
                    {
                        Console.WriteLine("Virtual Machine name specified "
                                          + cb.get_option("vmname") + " is a template");
                    }
                }
                else
                {
                    Console.WriteLine("Virtual Machine " + cb.get_option("vmname")
                                      + " Not Found");
                }
            }
            else
            {
                Console.WriteLine("Alarm Creation is not supported on an ESX server.");
            }
            cb.disConnect();
            Console.WriteLine("Please enter to exit.");
            Console.Read();
        }
        /**
         * Create method action to reboot the guest in a vm
         *
         * @return the action to run when the schedule runs
         */
        private Vim25Api.Action createTaskAction()
        {
            MethodAction action = new MethodAction();

            // Method Name is the WSDL name of the
            // ManagedObject's method to be run, in this Case,
            // the rebootGuest method for the VM
            action.name = "RebootGuest";

            // There are no arguments to this method
            // so we pass in an empty MethodActionArgument
            action.argument = new MethodActionArgument[] { };

            return(action);
        }
        /**
         * Create method action to reboot the guest in a vm
         * 
         * @return the action to run when the schedule runs
         */
        private Vim25Api.Action createTaskAction()
        {
            MethodAction action = new MethodAction();

            // Method Name is the WSDL name of the 
            // ManagedObject's method to be run, in this Case, 
            // the rebootGuest method for the VM
            action.name = "RebootGuest";

            // There are no arguments to this method
            // so we pass in an empty MethodActionArgument
            action.argument = new MethodActionArgument[] { };

            return action;
        }
        List <ActionObjectPath> IFieldUpdateStrategy.GetFieldUpdateAction(CSOMItemField fld, Identity identity)
        {
            MethodAction action = new MethodAction()
            {
                Id           = IdProvider.GetActionId(),
                Name         = "SetFieldValue",
                ObjectPathId = identity.Id.ToString(),
                Parameters   = fld.GetRequestParameters()
            };

            return(new List <ActionObjectPath>()
            {
                new ActionObjectPath()
                {
                    Action = action
                }
            });
        }
Exemplo n.º 15
0
        private void addMethodAction(Type fecadeService, string methodName, Type[] constructorParam,
                                     List <ActionType> actions)
        {
            MethodAction methodAction;

            if (constructorParam == null || !constructorParam.Any())
            {
                methodAction = new MethodAction(fecadeService.Name,
                                                fecadeService.GetMethod(methodName).Name, actions);
            }
            else
            {
                methodAction = new MethodAction(fecadeService.Name,
                                                fecadeService.GetMethod(methodName, constructorParam).Name, actions);
            }

            mapTable.Add(methodAction);
        }
        public void ProvisionTaxonomyFieldRequest_Test_GetCorrectRequest_WithoutParentId()
        {
            ProvisionTaxonomyFieldRequest request = new ProvisionTaxonomyFieldRequest("site-id", "web-id", "field-id", "", Guid.Parse("1e1a939f-60b2-2000-98a6-d25d3d400a3a"), Guid.Parse("740c6a0b-85e2-48a0-a494-e0f1759d4aa7"));

            var requests       = request.GetRequest(new IteratorIdProvider());
            var actionRequests = requests.Select(r => r.Action).ToList();
            var identities     = requests.Select(r => r.ObjectPath).Where(id => id != null).ToList();

            SetPropertyAction setTermStoreId    = actionRequests[0] as SetPropertyAction;
            SetPropertyAction setTermSetId      = actionRequests[1] as SetPropertyAction;
            SetPropertyAction setTargetTemplate = actionRequests[2] as SetPropertyAction;
            SetPropertyAction setAnchorId       = actionRequests[3] as SetPropertyAction;
            MethodAction      updateAction      = actionRequests[4] as MethodAction;

            Identity id = identities[0];

            Assert.AreEqual("SspId", setTermStoreId.Name);
            Assert.AreEqual(2, setTermStoreId.Id);
            Assert.AreEqual("1", setTermStoreId.ObjectPathId);
            Assert.AreEqual("1e1a939f-60b2-2000-98a6-d25d3d400a3a", setTermStoreId.SetParameter.Value.ToString());

            Assert.AreEqual("TermSetId", setTermSetId.Name);
            Assert.AreEqual(3, setTermSetId.Id);
            Assert.AreEqual("1", setTermSetId.ObjectPathId);
            Assert.AreEqual("740c6a0b-85e2-48a0-a494-e0f1759d4aa7", setTermSetId.SetParameter.Value.ToString());

            Assert.AreEqual("TargetTemplate", setTargetTemplate.Name);
            Assert.AreEqual(4, setTargetTemplate.Id);
            Assert.AreEqual("1", setTargetTemplate.ObjectPathId);
            Assert.AreEqual("", setTargetTemplate.SetParameter.Value.ToString());

            Assert.AreEqual("AnchorId", setAnchorId.Name);
            Assert.AreEqual(5, setAnchorId.Id);
            Assert.AreEqual("1", setAnchorId.ObjectPathId);
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", setAnchorId.SetParameter.Value.ToString());

            Assert.AreEqual("Update", updateAction.Name);
            Assert.AreEqual(6, updateAction.Id);
            Assert.AreEqual("1", updateAction.ObjectPathId);

            Assert.AreEqual("1e1a939f-60b2-2000-98a6-d25d3d400a3a|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:site-id:web:web-id:field:field-id", id.Name);
            Assert.AreEqual(1, id.Id);
        }
Exemplo n.º 17
0
        protected static void SetMethodAction(XElement element, MethodAction action)
        {
            switch (action)
            {
            case MethodAction.None:
                break;

            case MethodAction.Scan:
                element.SetAttributeValue("action", "scan");
                break;

            case MethodAction.Debug:
                element.SetAttributeValue("action", "debug");
                break;

            case MethodAction.Warn:
                element.SetAttributeValue("action", "warn");
                break;

            case MethodAction.Fail:
                element.SetAttributeValue("action", "fail");
                break;

            case MethodAction.ReturnFalse:
                element.SetAttributeValue("action", "return-false");
                break;

            case MethodAction.ReturnTrue:
                element.SetAttributeValue("action", "return-true");
                break;

            case MethodAction.ReturnNull:
                element.SetAttributeValue("action", "return-null");
                break;

            case MethodAction.Throw:
                element.SetAttributeValue("action", "throw");
                break;

            default:
                throw DebugHelpers.AssertFail($"Invalid method action: `{action}`.");
            }
        }
Exemplo n.º 18
0
        internal static bool TryParseMethodAction(string name, out MethodAction action)
        {
            switch (name.ToLowerInvariant())
            {
            case "return-null":
                action = MethodAction.ReturnNull;
                return(true);

            case "return-false":
                action = MethodAction.ReturnFalse;
                return(true);

            case "return-true":
                action = MethodAction.ReturnTrue;
                return(true);

            default:
                return(Enum.TryParse(name, true, out action));
            }
        }
Exemplo n.º 19
0
        List <ActionObjectPath> IFieldUpdateStrategy.GetFieldUpdateAction(CSOMItemField fld, Identity identity)
        {
            //Get field
            ObjectPathMethod getFieldByInternalNameMethod = new ObjectPathMethod
            {
                Id         = IdProvider.GetActionId(),
                ParentId   = FieldsProperty.Id,
                Name       = "GetByInternalNameOrTitle",
                Parameters = new MethodParameter()

                {
                    Properties = new List <Parameter>()
                    {
                        new Parameter()
                        {
                            Type  = "String",
                            Value = fld.FieldName
                        }
                    }
                }
            };

            MethodAction setFieldValueByValue = new MethodAction
            {
                ObjectPathId = getFieldByInternalNameMethod.Id.ToString(),
                Id           = IdProvider.GetActionId(),
                Name         = "SetFieldValueByValue",
                Parameters   = fld.GetRequestParameters(identity.Id)
            };

            return(new List <ActionObjectPath>()
            {
                new ActionObjectPath()
                {
                    Action = setFieldValueByValue,
                    ObjectPath = getFieldByInternalNameMethod
                }
            });
        }
Exemplo n.º 20
0
        /// <summary>
        /// запись начала или конца метода в консоль
        /// </summary>
        private static void WriteStartStopMethodConsoleLog(string methodName, MethodAction methodAction, bool anotherThread = false)
        {
            if (!MainData.ConsoleActive)
            {
                return;
            }
            var action = methodAction == MethodAction.Start ? "STARTED" : "ENDED";

            if (!anotherThread)
            {
                MainData.LogConsole.AddLog($"---{methodName} is {action}");
                MainData.LogConsole.Scroller.ScrollToEnd();
            }
            else
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    MainData.LogConsole.AddLog($"---{methodName} is {action}");
                    MainData.LogConsole.Scroller.ScrollToEnd();
                });
            }
        }
Exemplo n.º 21
0
 static void MarkMethod(LinkContext context, MethodDefinition method, MethodAction action)
 {
     context.Annotations.Mark(method);
     context.Annotations.SetAction(method, action);
 }
Exemplo n.º 22
0
		public void SetAction (MethodDefinition method, MethodAction action)
		{
			method_actions [method] = action;
		}
Exemplo n.º 23
0
 public static void SetAction(MethodDefinition method, MethodAction action)
 {
     SetAction(AsProvider(method), action);
 }
        List <ActionObjectPath> IFieldUpdateStrategy.GetFieldUpdateAction(CSOMItemField fld, Identity identity)
        {
            int getByInternalNameOrTitleId     = IdProvider.GetActionId();
            int taxonomyParameterConstructorId = IdProvider.GetActionId();
            //Set field value
            MethodAction setFieldValueByValue = new MethodAction
            {
                ObjectPathId = getByInternalNameOrTitleId.ToString(),
                Id           = IdProvider.GetActionId(),
                Name         = "SetFieldValueByValueCollection",
                Parameters   = new List <Parameter>()
                {
                    new ObjectReferenceParameter()
                    {
                        ObjectPathId = identity.Id
                    },
                    new ObjectReferenceParameter()
                    {
                        ObjectPathId = taxonomyParameterConstructorId
                    }
                }
            };

            //Get field
            ObjectPathMethod getFieldByInternalNameMethod = new ObjectPathMethod
            {
                Id         = getByInternalNameOrTitleId,
                ParentId   = FieldsProperty.Id,
                Name       = "GetByInternalNameOrTitle",
                Parameters = new MethodParameter()
                {
                    Properties = new List <Parameter>()
                    {
                        new Parameter()
                        {
                            Type  = "String",
                            Value = fld.FieldName
                        }
                    }
                }
            };

            //Create taxonomy collection
            List <Parameter> parameters = fld.GetRequestParameters(/*identity.Id*/ getByInternalNameOrTitleId);

            parameters.Reverse();

            ConstructorPath taxonomyCollectionConstructor = new ConstructorPath
            {
                Id         = taxonomyParameterConstructorId,
                TypeId     = "{c3dfae10-f3bf-4894-9012-bb60665b6d91}",
                Parameters = new MethodParameter()
                {
                    Properties = parameters
                }
            };

            ActionObjectPath setTaxonomyActionObject = new ActionObjectPath()
            {
                Action     = setFieldValueByValue,
                ObjectPath = getFieldByInternalNameMethod
            };

            ActionObjectPath constructTaxonomyCollection = new ActionObjectPath()
            {
                ObjectPath = taxonomyCollectionConstructor
            };

            return(new List <ActionObjectPath>()
            {
                setTaxonomyActionObject,
                constructTaxonomyCollection
            });
        }
 public ClrMethodOperation(ClrMethodInfo methodInfo, MethodAction action, DateTime time)
 {
     MethodInfo = methodInfo;
     Action = action;
     Time = time;
 }
Exemplo n.º 26
0
        public Player()
            : base()
        {
            isToLeft   = true;
            canClimb   = true;
            isFalling  = false;
            comboCount = 0;

            isPoweredUp = false;

            m_actionManager   = new SingleActionManager();
            m_spriteAnimation = new SingleActionManager();

            m_spriteTransform                 = new Transform(m_transform, true);
            m_leftTransform                   = new Transform(m_transform, true);
            m_rightTransform                  = new Transform(m_transform, true);
            m_bounceTransform                 = new Transform(m_transform, true);
            m_soulHotspot                     = new Transform(m_spriteTransform, true);
            m_soulHotspot.Position            = new Vector2(10, -10);
            m_soulAbsorptionPosition          = new Transform(m_spriteTransform, true);
            m_soulAbsorptionPosition.Position = new Vector2(0, 1);

            m_transform.PosX          = -walkingDistance;
            m_spriteTransform.PosX    = DistanceFromTotemCenter;
            m_leftTransform.Position  = new Vector2(DistanceFromTotemCenter, 0);
            m_rightTransform.Position = new Vector2(-DistanceFromTotemCenter, 0);

            m_sprite = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("player", 4, 8), m_spriteTransform);

            m_spriteAura        = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("power_up"), new Transform(m_spriteTransform, true));
            m_spriteAura.Origin = new Vector2(-2f, 0.5f);
            //m_spriteAura.Transform.PosX = -5;
            m_spriteAura.Transform.Scale = new Vector2(0);


            // Mouvement walkingToTotem
            // Mouvement d'introduction au jeu : on voit le personnage à distance, puis
            // quand on commence, il se rapproche du totem
            //
            m_walkingToTotem = new MoveToTransform(Program.TheGame, m_transform, m_transform, new Transform(), 1);
            m_walkingToTotem.Interpolator   = new PSmoothstepInterpolation();
            m_walkingToTotem.Timer.Interval = walkingDuration;

            #region Slash Animations
            ///
            ///	Slash left to right.
            ///	Le mouvement est exécuté en parallèle avec une séquence délai + action.
            ///	Autrement dit, vers la moitié de l'animation, il y a test de collision.
            ///	Comme ça, le bloc peut être éjecté à un moment très précis, et il n'y a pas de collisions intempestives.
            ///	On a: Concurrent(Mouvement + Sequence(delai => test collision))
            ///
            m_movementLR = new MoveToTransform(Program.TheGame, m_spriteTransform, m_leftTransform, m_rightTransform, 1);
            m_movementLR.Interpolator   = new PSmoothstepInterpolation();
            m_movementLR.Timer.Interval = SlashDuration;
            m_slashDelayLR = new DelayAction(Program.TheGame, CollisionDelayDuration);
            MethodAction collisionLR   = new MethodAction(delegate() { DoCollisionWithSections(false); });
            Sequence     slashActionLR = new Sequence(1);
            slashActionLR.AddAction(m_slashDelayLR);
            slashActionLR.AddAction(collisionLR);
            m_slashLR = new Concurrent(new PastaGameLibrary.Action[] { slashActionLR, m_movementLR });

            m_metalBounceLR = new MoveToTransform(Program.TheGame, m_spriteTransform, m_bounceTransform, m_leftTransform, 1);
            m_metalBounceLR.Timer.Interval = SlashDuration - CollisionDelayDuration;             //Le reste de temps après la collision

            ///
            /// Slash Right To Left
            /// Même principe que l'autre sens
            ///
            m_movementRL = new MoveToTransform(Program.TheGame, m_spriteTransform, m_rightTransform, m_leftTransform, 1);
            m_movementRL.Interpolator   = new PSmoothstepInterpolation();
            m_movementRL.Timer.Interval = SlashDuration;

            m_slashDelayRL = new DelayAction(Program.TheGame, CollisionDelayDuration);
            MethodAction collisionRL   = new MethodAction(delegate() { DoCollisionWithSections(true); });
            Sequence     slashActionRL = new Sequence(1);
            slashActionRL.AddAction(m_slashDelayRL);
            slashActionRL.AddAction(collisionRL);
            m_slashRL = new Concurrent(new PastaGameLibrary.Action[] { slashActionRL, m_movementRL });

            #endregion

            #region Bounce Animations
            //
            // Mouvement de rebond volontaire gauche
            //
            m_bounceMovementLL = new MoveToTransform(Program.TheGame, m_spriteTransform, m_leftTransform, m_bounceTransform, 1);
            m_bounceMovementLL.Timer.Interval = SlashDuration;
            m_bounceMovementLL.Interpolator   = new PBounceInterpolation(0.5f);
            MethodAction actionL = new MethodAction(
                delegate()
            {
                m_bounceTransform.PosY = 0;
                m_bounceTransform.PosX = m_leftTransform.PosX + (m_rightTransform.PosX - m_leftTransform.PosX) * CollisionDelayRatio;
            });
            m_slashBounceLR = new Concurrent(new PastaGameLibrary.Action[] { actionL, slashActionLR, m_bounceMovementLL });

            //
            // Mouvement de rebond volontaire droite
            //
            m_bounceMovementRR = new MoveToTransform(Program.TheGame, m_spriteTransform, m_rightTransform, m_bounceTransform, 1);
            m_bounceMovementRR.Timer.Interval = SlashDuration;
            m_bounceMovementRR.Interpolator   = new PBounceInterpolation(0.5f);
            MethodAction actionR = new MethodAction(
                delegate()
            {
                m_bounceTransform.PosY = 0;
                m_bounceTransform.PosX = m_rightTransform.PosX - (m_rightTransform.PosX - m_leftTransform.PosX) * CollisionDelayRatio;
            });
            m_slashBounceRL = new Concurrent(new PastaGameLibrary.Action[] { actionR, slashActionRL, m_bounceMovementRR });

            m_metalBounceRL = new MoveToTransform(Program.TheGame, m_spriteTransform, m_bounceTransform, m_rightTransform, 1);
            m_metalBounceRL.Timer.Interval = SlashDuration - CollisionDelayDuration;             //Le reste de temps après la collision

            #endregion

            m_spritAnimLR          = new SpriteSheetAnimation(m_sprite, 0, 7, SlashDuration, 1);
            m_spritAnimRL          = new SpriteSheetAnimation(m_sprite, 8, 15, SlashDuration, 1);
            m_spritAnimLL          = new SpriteSheetAnimation(m_sprite, 16, 23, SlashDuration, 1);
            m_spritAnimRR          = new SpriteSheetAnimation(m_sprite, 23, 30, SlashDuration, 1);
            m_ready                = new SpriteSheetAnimation(m_sprite, 0, 4, SlashDuration, 1);
            m_ready.Timer.Interval = 0.5f;
        }
Exemplo n.º 27
0
        public static void Initalise()
        {
            cutscenePlayer = new CutscenePlayer();
            cutscenePlayer.Transform.PosX = -100;
            monster = new Monster();
            crowd   = new Crowd(40, 18, new Vector2(2.5f, 0.5f));

            title = new Title();

            DelayAction cameraDelay = new DelayAction(Program.TheGame, CameraDelay);

            moveToTotem = new MoveToStaticAction(Program.TheGame, Game1.GameCamera.Transform, Vector2.Zero, 1);
            moveToTotem.StartPosition  = new Vector2(CameraMenuX, CameraMenuY);
            moveToTotem.Interpolator   = new PSmoothstepInterpolation();
            moveToTotem.Timer.Interval = TimeToFirstTotem;
            MethodAction moveCrowd = new MethodAction(delegate() {
                crowd.MoveTo(currentTotemPosition + TotemCrowdOffset, TimeToFirstTotem);
            });

            gotoFirstTotem = new Sequence(1);
            gotoFirstTotem.AddAction(cameraDelay);
            gotoFirstTotem.AddAction(moveCrowd);
            gotoFirstTotem.AddAction(moveToTotem);
            gotoFirstTotem.AddAction(new MethodAction(delegate() { Cutscenes.ThrowPlayer(Game1.CurrentTotem); }));

            playerLaunch = new Sequence(1);
            playerLaunch.AddAction(new DelayAction(Program.TheGame, Crowd.LaunchTensionTime));
            moveToAscendingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), cutscenePlayer.Transform, 1);
            moveToAscendingPlayer.Interpolator   = new PSquareInterpolation(0.1f);
            moveToAscendingPlayer.RotationActive = false;
            playerLaunch.AddAction(moveToAscendingPlayer);

            readySequence = new Sequence(1);
            Transform end = new Transform(Game1.player.Transform, true);

            end.PosY            = Game1.CameraOffset;
            moveToFallingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), end, 1);
            moveToFallingPlayer.Interpolator   = new PSmoothstepInterpolation();
            moveToFallingPlayer.RotationActive = false;

            readySequence.AddAction(new MethodAction(delegate() { Game1.player.GetReady(); }));
            readySequence.AddAction(moveToFallingPlayer);
            readySequence.AddAction(new MethodAction(delegate() { Game1.player.StartCountDown(); }));

            cameraZoom = new ScaleToAction(Program.TheGame, Game1.GameCamera.Transform, Vector2.Zero, 1);
            cameraZoom.Interpolator   = new PSmoothstepInterpolation();
            cameraZoom.Timer.Interval = 0.3f;

            goToPlayerOnGround         = new Sequence(1);
            goToPlayerOnGroundMovement = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), cutscenePlayer.Transform, 1);
            goToPlayerOnGroundMovement.Timer.Interval = 1.0f;
            goToPlayerOnGroundMovement.Interpolator   = new PSmoothstepInterpolation();
            goToPlayerOnGround.AddAction(new DelayAction(Program.TheGame, 0.5f));
            goToPlayerOnGround.AddAction(goToPlayerOnGroundMovement);

            intro = new Sequence(1);
            MoveToStaticAction moveToMenu = new MoveToStaticAction(Program.TheGame, Game1.GameCamera.Transform, new Vector2(CameraMenuX, CameraMenuY), 1);

            moveToMenu.Timer.Interval = MoveInTime + 1.0f;

            intro.AddAction(moveToMenu);
            intro.AddAction(new MethodAction(delegate() { crowd.PushNewGuy(); }));
            intro.AddAction(new DelayAction(Program.TheGame, 1.5f));
            intro.AddAction(new MethodAction(delegate() { StartMainMenu(); }));

            goToCliff = new Sequence(1);
            goToCliff.AddAction(moveToTotem);
            goToCliff.AddAction(new MethodAction(delegate() { cutscenePlayer.GiveSouls(Game1.TotalScore); monster.OpenMouth(); }));

            auraTexture = TextureLibrary.GetSpriteSheet("soul_temp");
            soulTexture = TextureLibrary.GetSpriteSheet("soul");
            //moveToAscendingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), cutscenePlayer.Transform, 1);
        }
Exemplo n.º 28
0
 public ClrMethodOperation(ClrMethodInfo methodInfo, MethodAction action, DateTime time)
 {
     MethodInfo = methodInfo;
     Action     = action;
     Time       = time;
 }
Exemplo n.º 29
0
        public Crowd(int amountOfPopulation, float radius, Vector2 sizeRatio)
        {
            m_radius    = radius;
            m_sizeRatio = sizeRatio;

            m_playerCharacterTransform           = new Transform(m_transform, true);
            m_playerCharacterTransform.Direction = 1.56f;
            m_playerCharacterTransform.PosY      = -25;

            int   maxIndex;
            float currentRadius, currentAngle;

            //Générer le devant
            maxIndex = (int)(amountOfPopulation * FrontToBackRatio);
            for (int i = 0; i < amountOfPopulation; ++i)
            {
                currentRadius = (float)(Program.Random.NextDouble() * m_radius);
                currentAngle  = (float)(Program.Random.NextDouble() * 6.28);
                Vector2    position = new Vector2((float)Math.Cos(currentAngle) * currentRadius * m_sizeRatio.X, (float)Math.Sin(currentAngle) * currentRadius * m_sizeRatio.Y);
                Individual individu = new Individual(this, position);
                m_people.Add(individu);
                if (individu.Transform.PosY > 0)
                {
                    m_frontPeople.Add(individu);
                }
                else
                {
                    m_backPeople.Add(individu);
                }
            }

            m_frontPeople = m_frontPeople.OrderBy(o => o.Transform.PosY).ToList();

            ///
            /// MoveTo animation
            ///
            m_moveToMovement = new MoveToStaticAction(Program.TheGame, m_transform, Vector2.Zero, 1);
            MethodAction stopWalk = new MethodAction(delegate() { for (int i = 0; i < m_people.Count; ++i)
                                                                  {
                                                                      m_people[i].StopWalk();
                                                                  }
                                                     });

            m_moveTo = new Sequence(1);
            m_moveTo.AddAction(m_moveToMovement);
            m_moveTo.AddAction(stopWalk);

            ///
            /// Pickup player animation
            ///
            m_pickupPlayer = new Sequence(1);
            m_pickupPlayer.AddAction(m_moveToMovement);
            //m_pickupPlayer.AddAction(new DelayAction(Program.TheGame, 0.1f));
            m_pickupPlayer.AddAction(new MethodAction(delegate() { Cutscenes.cutscenePlayer.JumpOnCrowd(); }));
            m_animationManager = new SingleActionManager();

            ///
            /// Pickup player animation
            ///
            m_pushNewGuy = new MoveToStaticAction(Program.TheGame, m_transform, Vector2.Zero, 1);
            m_pushNewGuy.Interpolator   = new PBounceInterpolation(0.5f);
            m_pushNewGuy.Timer.Interval = 0.2f;
        }
Exemplo n.º 30
0
        public CutscenePlayer()
            : base()
        {
            m_ascendSound = SoundEffectLibrary.Get("ascend").CreateInstance();
            m_cloud       = new Prop("cloud");
            m_sword       = new Prop("sword");

            m_shlingSprite = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("shling"), new Transform(m_transform, true));

            m_sprite                 = new PastaGameLibrary.Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("player_cutscene", 1, 4), new Transform(m_transform, true));
            m_sprite.Origin          = new Vector2(0.5f, 0.5f);
            m_sprite.PixelCorrection = false;

            m_moveToCrowd = new MoveToTransform(Program.TheGame, m_transform, null, null, 1);
            m_moveToCrowd.Timer.Interval = 0.1f;
            MoveToStaticAction carryMovement = new MoveToStaticAction(Program.TheGame, m_transform, new Vector2(0, CarryHeight - 5), 1);

            carryMovement.Interpolator   = new PBounceInterpolation(1.0f);
            carryMovement.StartPosition  = new Vector2(0, CarryHeight);
            carryMovement.Timer.Interval = 0.2f;
            MethodAction action = new MethodAction(delegate() { carryMovement.StartPosition = new Vector2(0, CarryHeight); });

            Sequence bounceAnimation = new Sequence(-1);

            bounceAnimation.AddAction(carryMovement);
            bounceAnimation.AddAction(action);

            m_carryAnimation = new Sequence(1);
            m_carryAnimation.AddAction(m_moveToCrowd);
            m_carryAnimation.AddAction(bounceAnimation);


            //Sword movement
            Transform start = new Transform(m_transform, true);
            Transform end   = new Transform(m_transform, true);

            m_swordMovement = new MoveToTransform(Program.TheGame, m_sword.Transform, start, end, 1);
            end.PosX        = SwordOffsetToPlayerX;
            end.PosY        = SwordOffsetToPlayerY;
            m_swordDelay    = new DelayAction(Program.TheGame, AscendDuration * SwordStartTimeRatio);

            //Cloud movement
            m_cloudMovement = new MoveToStaticAction(Program.TheGame, m_cloud.Transform, new Vector2(CloudOffsetToPlayerX, CloudOffsetToPlayerY), 1);
            m_cloudMovement.StartPosition = new Vector2(CloudStartX, 0);
            m_cloudMovement.Interpolator  = new PSquareInterpolation(0.25f);

            //Delay of the ascend, then sword/cloud movement
            Sequence swordAndCloudMovement = new Sequence(1);

            swordAndCloudMovement.AddAction(m_swordDelay);
            swordAndCloudMovement.AddAction(new Concurrent(new PastaGameLibrary.Action[] { m_swordMovement, m_cloudMovement }));

            m_ascendMovement = new MoveToTransform(Program.TheGame, m_transform, new Transform(), new Transform(), 1);
            m_ascendMovement.Interpolator = new PSquareInterpolation(0.5f);

            MethodAction showPlayer = new MethodAction(delegate()
            {
                m_sprite.Transform.PosY -= 1;
                Game1.player.ShowPlayer();
                isVisible         = false;
                m_cloud.IsVisible = false;
                m_sword.IsVisible = false;
            });

            //Shling!
            ScaleToAction shlingScale = new ScaleToAction(Program.TheGame, m_shlingSprite.Transform, new Vector2(ShlingScale, ShlingScale), 1);

            shlingScale.Timer.Interval = ShlingTime;
            shlingScale.StartScale     = Vector2.Zero;
            shlingScale.Interpolator   = new PSquareInterpolation(2);

            RotateToStaticAction shlingRotate = new RotateToStaticAction(Program.TheGame, m_shlingSprite.Transform, ShlingSpin, 1);

            shlingRotate.Timer.Interval = ShlingTime;
            m_shling = new Concurrent(new PastaGameLibrary.Action[] { shlingScale, shlingRotate });

            Sequence readyAnim = new Sequence(1);

            readyAnim.AddAction(new DelayAction(Program.TheGame, 0.5f));
            readyAnim.AddAction(new MethodAction(delegate() {
                Cutscenes.GetReady();
                SoundEffectLibrary.Get("sword_slash").Play();
            }));

            Concurrent shlingReady = new Concurrent(new PastaGameLibrary.Action[] {
                m_shling,
                readyAnim,
            });

            m_ascend = new Sequence(1);
            m_ascend.AddAction(new DelayAction(Program.TheGame, Crowd.LaunchTensionTime));
            m_ascend.AddAction(new MethodAction(delegate() { m_ascendSound.Play(); }));
            Concurrent ascendAndSword = new Concurrent(new PastaGameLibrary.Action[] { m_ascendMovement, swordAndCloudMovement });

            m_ascend.AddAction(ascendAndSword);
            m_ascend.AddAction(showPlayer);
            m_ascend.AddAction(shlingReady);

            m_physics      = new PhysicsComponent(Program.TheGame, m_transform);
            m_physics.Mass = 3.0f;

            m_jumpFromTotem           = new Sequence(1);
            m_decelerate              = new MoveToStaticAction(Program.TheGame, m_transform, Vector2.Zero, 1);
            m_decelerate.Interpolator = new PSquareInterpolation(0.5f);
            m_jumpFromTotem.AddAction(m_decelerate);
            m_jumpFromTotem.AddAction(new DelayAction(Program.TheGame, 0.2f));
            m_jumpFromTotem.AddAction(new MethodAction(delegate()
            {
                m_physics.OnBounce = null;
                m_physics.Throw(1.0f, -2.0f, 0);
                Game1.CurrentMusic.StopDynamicMusic();
                SoundEffectLibrary.Get("sword_slash").Play();
            }));
            m_jumpFromTotem.AddAction(new DelayAction(Program.TheGame, 0.75f));
            m_jumpFromTotem.AddAction(new MethodAction(delegate()
            {
                Game1.SetupNextRound();
                if (Game1.CurrentTotem == null)
                {
                    Cutscenes.GoToCliff();
                }
                else
                {
                    Cutscenes.GoToTotem(Game1.CurrentTotem, 1.0f, 0);
                }
            }));
            m_actionManager = new SingleActionManager();

            m_hitSpikes = new Sequence(1);

            m_moveToCrashingPlayer = new MoveToTransform(Program.TheGame, Game1.GameCamera.Transform, new Transform(), new Transform(), 1);
            m_moveToCrashingPlayer.Timer.Interval = 0.2f;

            m_hitSpikes.AddAction(new DelayAction(Program.TheGame, 1.0f));
            m_hitSpikes.AddAction(m_moveToCrashingPlayer);
            m_hitSpikes.AddAction(new DelayAction(Program.TheGame, 0.5f));
            m_hitSpikes.AddAction(new MethodAction(delegate() {
                if (Game1.CurrentTotem == null)
                {
                    Cutscenes.GoToCliff();
                }
                else
                {
                    Cutscenes.GoToTotem(Game1.CurrentTotem, 1.0f, 0);
                }
                m_sprite.SetFrame(0);
                m_physics.OnBounce = null;
                m_physics.Throw(0, -3, 0);
                m_transform.PosY = m_physics.GroundLevel;
            }));

            m_auraParticles = new ParticleSystem(Program.TheGame, 100);
            m_soulParticles = new ParticleSystem(Program.TheGame, 500);

            m_levitate       = new Sequence(1);
            m_moveToCliffTip = new MoveToStaticAction(Program.TheGame, m_transform, new Vector2(Cutscenes.InitialCharacterPosition + 10, -8), 1);
            m_moveToCliffTip.Interpolator   = new PSmoothstepInterpolation();
            m_moveToCliffTip.Timer.Interval = 1.0f;
            m_levitate.AddAction(m_moveToCliffTip);
            m_levitate.AddAction(new MethodAction(delegate() { m_generateSouls = true; }));

            m_particleGenerator                    = new ParticleGenerator <GlitterParticle>(Program.TheGame, m_auraParticles);
            m_particleGenerator.Automatic          = true;
            m_particleGenerator.GenerationInterval = 0.01f;
            m_soulParticleGenerator                = new ParticleGenerator <SoulParticle>(Program.TheGame, m_soulParticles);

            m_jumpInMouth = new Sequence(1);
            m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 0.5f));
            m_jumpInMouth.AddAction(new MethodAction(delegate() { m_generateSouls = false; }));
            m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 0.5f));
            m_jumpInMouth.AddAction(new MethodAction(delegate() { JumpInMonsterMouth(); }));
            m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 0.25f));
            m_jumpInMouth.AddAction(new MethodAction(delegate() { Cutscenes.monster.CloseMouth(); }));
            m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 2.0f));
            m_jumpInMouth.AddAction(new MethodAction(delegate() { Cutscenes.crowd.PushNewGuy(); }));
            m_jumpInMouth.AddAction(new DelayAction(Program.TheGame, 1.0f));
            m_jumpInMouth.AddAction(new MethodAction(delegate() { Cutscenes.StartMainMenu(); }));
        }
Exemplo n.º 31
0
 static void MarkMethod(LinkContext context, MethodDefinition method, MethodAction action)
 {
     context.Annotations.Mark (method);
     context.Annotations.SetAction (method, action);
 }
Exemplo n.º 32
0
        public void SetupInput()
        {
            // Get the move method
            var moveMethod = this.GetType().GetMethod(nameof(Move));

            // Define actions
            var moveLeftAction = new MethodAction(moveMethod, this)
            {
                Values =
                {
                    new ParameterValue()
                    {
                        Name  = "direction",
                        Value = MoveDirection.Left
                    },
                    new ParameterValue()
                    {
                        Name  = "amount",
                        Value = 20d
                    }
                }
            };

            var jumpLeftAction = new MethodAction(moveMethod, this)
            {
                Values =
                {
                    new ParameterValue()
                    {
                        Name  = "direction",
                        Value = MoveDirection.Left
                    },
                    new ParameterValue()
                    {
                        Name  = "amount",
                        Value = 100d
                    }
                }
            };

            var moveRightAction = new MethodAction(moveMethod, this)
            {
                Values =
                {
                    new ParameterValue()
                    {
                        Name  = "direction",
                        Value = MoveDirection.Right
                    },
                    new ParameterValue()
                    {
                        Name  = "amount",
                        Value = 20d
                    }
                }
            };

            var jumpRightAction = new MethodAction(moveMethod, this)
            {
                Values =
                {
                    new ParameterValue()
                    {
                        Name  = "direction",
                        Value = MoveDirection.Right
                    },
                    new ParameterValue()
                    {
                        Name  = "amount",
                        Value = 100d
                    }
                }
            };

            // Create key bindings
            var moveLeftKey = new KeyBinding()
            {
                Key          = VirtualKey.Left,
                WhenRepeated = true,
                Action       = moveLeftAction
            };

            var jumpLeftKey = new KeyBinding()
            {
                Key          = VirtualKey.Left,
                Modifier     = VirtualKey.Shift,
                WhenRepeated = true,
                Action       = jumpLeftAction
            };

            var moveRightKey = new KeyBinding()
            {
                Key          = VirtualKey.Right,
                WhenRepeated = true,
                Action       = moveRightAction
            };

            var jumpRightKey = new KeyBinding()
            {
                Key          = VirtualKey.Right,
                WhenRepeated = true,
                Modifier     = VirtualKey.Shift,
                Action       = jumpRightAction
            };

            // Create key bindings
            var moveLeftJoy = new KeyBinding()
            {
                Key          = VirtualKey.GamepadDPadLeft,
                WhenRepeated = true,
                Action       = moveLeftAction
            };

            var jumpLeftJoy = new KeyBinding()
            {
                Key          = VirtualKey.GamepadDPadLeft,
                Modifier     = VirtualKey.GamepadLeftShoulder,
                WhenRepeated = true,
                Action       = jumpLeftAction
            };

            var moveRightJoy = new KeyBinding()
            {
                Key          = VirtualKey.GamepadDPadRight,
                WhenRepeated = true,
                Action       = moveRightAction
            };

            var jumpRightJoy = new KeyBinding()
            {
                Key          = VirtualKey.GamepadDPadRight,
                WhenRepeated = true,
                Modifier     = VirtualKey.GamepadLeftShoulder,
                Action       = jumpRightAction
            };


            // Create keyboard mapper
            var keyMapper = new KeyboardMapper()
            {
                Bindings =
                {
                    moveLeftKey,
                    moveRightKey,
                    jumpLeftKey,
                    jumpRightKey,
                    moveLeftJoy,
                    moveRightJoy,
                    jumpLeftJoy,
                    jumpRightJoy
                }
            };

            // Start listening to events
            keyMapper.SubscribeEvents();
        }
 static void MarkMethod(MethodDefinition method, MethodAction action, object reason)
 {
     Annotations.Mark (method, reason);
     Annotations.SetAction (method, action);
 }
Exemplo n.º 34
0
 public static void SetAction(MethodDefinition method, MethodAction action)
 {
     SetAction (AsProvider (method), action);
 }
 static void MarkMethod(MethodDefinition method, MethodAction action, TypeDefinition markedby)
 {
     Annotations.Mark(method, markedby);
     Annotations.SetAction(method, action);
 }
Exemplo n.º 36
0
 public void SetAction(MethodDefinition method, MethodAction action)
 {
     method_actions [method] = action;
 }
Exemplo n.º 37
0
 static void MarkMethod(MethodDefinition method, MethodAction action)
 {
     Annotations.Mark(method);
     Annotations.SetAction(method, action);
 }
Exemplo n.º 38
0
 public void SetAction(MethodDefinition method, MethodAction action)
 {
     throw null;
 }
Exemplo n.º 39
0
        void SetSafestActionForETWMethod(AnnotationStore annotations, MethodDefinition method, MethodAction desiredAction)
        {
            if (desiredAction == MethodAction.ConvertToThrow)
            {
                // If the desired action is a throw but the method has a void return let's just clear the body.
                // If the method does not have a void return, let's still insert a throw just in case.  stubbing the body could result in
                // an unexpected value being returned from the method which may lead to a more confusing error down the road
                if (method.ReturnType.MetadataType == MetadataType.Void)
                {
                    annotations.SetAction(method, MethodAction.ConvertToStub);
                    return;
                }

                if (!MethodBodyScanner.IsWorthConvertingToThrow(method.Body))
                {
                    return;
                }
            }

            annotations.SetAction(method, desiredAction);
        }