Beispiel #1
0
    public override void Execute()
    {
        ExecuteMethod.OnceInUpdate("SquadChildFSM.UpdateLandmineList", null, null);

        m_scFSM.Strafing();

        // if: There is more landmine than the production child count
        if (SquadChildFSM.ListLandmine.Count >= SquadChildFSM.StateCount(SCState.Produce))
        {
            for (int i = 0; i < SquadChildFSM.ListLandmine.Count; i++)
            {
                if (Vector3.Distance(SquadChildFSM.ListLandmine[i].transform.position, m_scFSM.transform.position) < 2f)
                {
                    m_scFSM.Advance(SCState.Avoid);
                    return;
                }
            }
        }
        // else if: There is lesser landmine state BUT not 0
        else if (SquadChildFSM.ListLandmine.Count != 0)
        {
            for (int i = 0; i < SquadChildFSM.ListLandmine.Count; i++)
            {
                if (Vector3.Distance(SquadChildFSM.ListLandmine[i].transform.position, m_scFSM.transform.position) < 2f)
                {
                    m_scFSM.Advance(SCState.Attack);
                    return;
                }
            }
        }
    }
Beispiel #2
0
 private void Execute(ExecuteMethod executeMethod)
 {
     if (IsExecuteMethodSelected(executeMethod))
     {
         Execute();
     }
 }
Beispiel #3
0
 public State(ExecuteMethod executeMethod, DecideMethod decideMethod, EnterMethod enterMethod, ExitMethod exitMethod)
 {
     this.executeMethod = executeMethod;
     this.decideMethod  = decideMethod;
     this.enterMethod   = enterMethod;
     this.exitMethod    = exitMethod;
 }
        internal static void TestExecuteSourcesNoInput(string[] sources, string baseline, string testname, ExecuteMethod method)
        {
            LOLCodeCodeProvider provider = new LOLCodeCodeProvider();
            string assemblyName = String.Format("{0}.exe", testname);
            CompilerParameters cparam = GetDefaultCompilerParams(assemblyName, method);

            // Compile test
            CompilerResults results = provider.CompileAssemblyFromSourceBatch(cparam, sources);

            // Collect errors (if any)
            StringBuilder errors = new StringBuilder();
            if (results.Errors.HasErrors)
            {
                for (int i = 0; i < results.Errors.Count; i++)
                {
                    errors.AppendLine(results.Errors[i].ToString());
                }
            }

            // Ensure there are no errors before trying to execute
            Assert.AreEqual(0, results.Errors.Count, errors.ToString());

            if (method == ExecuteMethod.InMemory)
            {
                throw new NotImplementedException("In memory execution is not implimented yet");
            }
            else
            {
                // Run the executeable (collecting it's output) compare to baseline
                Assert.AreEqual(baseline, RunExecuteable(assemblyName));
                File.Delete(assemblyName);
            }
        }
Beispiel #5
0
    // Execute(): When the squad child is in this state. Runs once every frame on every instance
    public override void Execute()
    {
        // Calculates the velocity for all children
        ExecuteMethod.OnceInUpdate("SC_IdleState.CalculateVelocity", null, null);

        // toTargetVector: The vector from its tranform position to the angular position
        Vector3 toTargetVector = PlayerSquadFSM.Instance.transform.position + Quaternion.Euler(0.0f, 0.0f, fAngularPosition) * Vector3.up * s_fIdleRadius - m_scFSM.transform.position;

        if (toTargetVector.magnitude > s_fIdleRigidity)
        {
            m_scFSM.m_RigidBody.AddForce(toTargetVector);
        }
        m_scFSM.m_RigidBody.velocity = Vector3.ClampMagnitude(m_scFSM.m_RigidBody.velocity, Mathf.Max(s_fIdleRigidity, toTargetVector.magnitude));

        fAngularPosition += fAngularVelocity * Time.deltaTime;
        // if, else if: Clamping values to be within 0 to 360f
        if (fAngularPosition > 360.0f)
        {
            fAngularPosition -= 360.0f;
        }
        else if (fAngularPosition < 0.0f)
        {
            fAngularPosition += 360.0f;
        }
    }
        public ExecuteMethod GetExecuteMethodDescriptor(string name, Type returnType, params object[] arg)
        {
            /*byte[][] arguments = null;
             * if ((arg?.Length??0) > 0)
             * {
             *  arguments = new byte[arg.Length][];
             *  using (var mm = MemoryManager.Instance.GetStream())
             *  {
             *      int i = 0;
             *      foreach (var a in arg)
             *      {
             *          mm.SetLength(0);
             *          Host.Serializer.Serialize(a, mm, out _);
             *          arguments[i++] = mm.ToArray();
             *      }
             *  }
             *
             * }*/
            var exe = new ExecuteMethod
            {
                Eid = _Eid,
                //Arguments = arguments,
                Method = name,
                //_ReturnType = returnType
                Objects = arg
            };

            return(exe);
        }
Beispiel #7
0
 public State(ExecuteMethod executeMethod, DecideMethod decideMethod, EnterMethod enterMethod, ExitMethod exitMethod)
 {
     this.executeMethod	= executeMethod;
     this.decideMethod	= decideMethod;
     this.enterMethod	= enterMethod;
     this.exitMethod = exitMethod;
 }
 protected void Execute(ExecuteMethod executeMethod)
 {
     if (IsExecuteMethodSelected(executeMethod))
     {
         Execute();
     }
 }
        public MethodDescriptor FindOverload(ExecuteMethod cmd)
        {
            foreach (var m in _methods[cmd.Method])
            {
                if (/*cmd._ReturnType.IsAssignableFrom(m.RealReturnType) &&*/
                    m.Parameters.Length == (cmd.Objects?.Length ?? 0))
                {
                    var i   = 0;
                    var err = false;
                    for (; i < m.Parameters.Length; i++)
                    {
                        var type = cmd.Objects[i]?.GetType();
                        if (type != null && !m.Parameters[i].Type.IsAssignableFrom(type))
                        {
                            err = true;
                            break;
                        }
                    }

                    if (err)
                    {
                        continue;
                    }
                    return(m);
                }
            }

            return(null);
        }
Beispiel #10
0
        public void CommandExecute(ProxyDbCommand command, TimeSpan duration, ExecuteMethod method, List<QueryExecutionPlan> executionPlan, object result)
        {
            if (!IsAvailable()) return;

            var commandMessage = new CommandMessage(command.CommandText, duration, method.ToString(), command.ProxyDbConnection.Context) { QueryExecutionPlans = executionPlan };

            GetChannel().CommandExecute(commandMessage);
        }
Beispiel #11
0
 private ppStage(string id, string name, ExecuteMethod method, bool isReceiveStage)
 {
     _id             = new Guid(id);
     _name           = name;
     _executeMethod  = method;
     _isReceiveStage = isReceiveStage;
     _stages.Add(_id, this);
 }
 private PipelineStage(string id, string name, ExecuteMethod method, bool isReceiveStage)
 {
    _id = new Guid(id);
    _name = name;
    _executeMethod = method;
    _isReceiveStage = isReceiveStage;
    _stages.Add(_id, this);
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="exec">The execute method</param>
 /// <param name="canExecutePredicate">Predicate Function without object parameter</param>
 public DelegateCommand(ExecuteMethod exec, Func <bool> canExecutePredicate)
     : this(exec)
 {
     canExecute = (obj) =>
     {
         return(canExecutePredicate.Invoke());
     };
 }
Beispiel #14
0
 public Command(string keyword, string description, bool echoCommand, Parameter[] parameters, ExecuteMethod method)
 {
     this.keyword     = keyword;
     this.description = description;
     this.echoCommand = echoCommand;
     this.parameters  = parameters;
     this.method      = method;
 }
Beispiel #15
0
 public Command(string keyword, string description, ExecuteMethod method)
 {
     this.keyword     = keyword;
     this.description = description;
     this.method      = method;
     parameters       = new Parameter[0];
     echoCommand      = true;
 }
 /// <summary>
 /// Instantiates a new RelayCommand with a delegate to be executed when the command is called, and a predicate to check if the command can be called.
 /// </summary>
 /// <param name="execute">The method to be exeucted when the command is called.</param>
 /// <param name="canExecute">The predicate to check if the command is callable.</param>
 public RelayCommand(ExecuteMethod execute, CanExecuteMethod canExecute)
 {
     if (execute == null)
     {
         throw new ArgumentNullException("execute");
     }
     _execute    = execute;
     _canExecute = canExecute;
 }
 private static CompilerParameters GetDefaultCompilerParams(string outfile, ExecuteMethod method)
 {
     CompilerParameters cparam = new CompilerParameters();
     cparam.GenerateExecutable = true;
     cparam.GenerateInMemory = (method == ExecuteMethod.InMemory) ? true : false;
     cparam.OutputAssembly = outfile;
     cparam.MainClass = "Program";
     cparam.IncludeDebugInformation = true;
     return cparam;
 }
Beispiel #18
0
    public override void Execute()
    {
        if (m_scFSM.attackTarget != null && !isColorChanged)
        {
            m_scFSM.m_SpriteRenderer.color = new Color(1f, 0.12f, 0.12f);
            isColorChanged = true;
        }

        ExecuteMethod.OnceInUpdate("SquadChildFSM.GetNearestTargetPosition", null, null);
        m_scFSM.AttackTarget();
    }
 public void FillInvocation(ExecuteMethod cmd, MethodDescriptor descriptor)
 {
     for (int i = 0; i < cmd.Objects.Length; i++)
     {
         var type = descriptor.Parameters[i].Type;
         if (descriptor.Parameters[i].IsDummy || (type.GetTypeInfo().IsValueType&& cmd.Objects[i] == null))
         {
             cmd.Objects[i] = Activator.CreateInstance(type);
         }
     }
 }
        private static CompilerParameters GetDefaultCompilerParams(string outfile, ExecuteMethod method)
        {
            CompilerParameters cparam = new CompilerParameters();

            cparam.GenerateExecutable      = true;
            cparam.GenerateInMemory        = (method == ExecuteMethod.InMemory) ? true : false;
            cparam.OutputAssembly          = outfile;
            cparam.MainClass               = "Program";
            cparam.IncludeDebugInformation = true;
            return(cparam);
        }
Beispiel #21
0
 public Stage(string name, ExecuteMethod executeMethod, Guid id, IPipeline pipeline)
 {
     if (pipeline == null)
     {
         throw new ArgumentNullException("pipeline");
     }
     this.name          = name;
     this.executeMethod = executeMethod;
     this.id            = id;
     this.pipeline      = pipeline;
 }
Beispiel #22
0
 private void EnableExecuteButton(bool enable, int imageIndex)
 {
     if (gridNavigator.InvokeRequired)
     {
         EnableExecuteButtonEvent d = new EnableExecuteButtonEvent(this.EnableExecuteButton);
         this.Invoke(d, new object[] { enable, imageIndex });
     }
     else
     {
         toolStripButtonExecute.Image = ilExecute.Images[imageIndex];
         _executeMethod = (ExecuteMethod)imageIndex;
         toolStripButtonExecute.Enabled = enable;
     }
 }
Beispiel #23
0
        private void method_10(IConnection iconnection_1, object object_1, Type type_0)
        {
            Controller.logger_0.Info("Received payload of type {type}", type_0.FullName);
            ExecuteMethod executeMethod = object_1 as ExecuteMethod;

            if (executeMethod != null)
            {
                Controller.logger_0.Info("method: {method}", executeMethod.Method);
                return;
            }
            EntangleResult entangleResult = object_1 as EntangleResult;

            if (entangleResult != null)
            {
                Controller.logger_0.Info <Guid?>("Entangled type: {type}", entangleResult.Eid);
            }
        }
Beispiel #24
0
    // Strafing(): Handles the movement when the cells are in production state
    public bool Strafing()
    {
        if (m_currentEnumState != SCState.Produce)
        {
            Debug.LogWarning(gameObject.name + ".SquadChildFSM.Strafing(): Current state is not SCState.Produce! Ignore Strafing!");
            return(false);
        }

        ExecuteMethod.OnceInUpdate("SquadChildFSM.StrafingVector", null, null);
        // targetPosition: The calculated target position - includes its angular offset from the main vector and the squad's captain position
        Vector3 targetPosition   = Quaternion.Euler(0.0f, 0.0f, fStrafingOffsetAngle) * m_strafingVector + PlayerSquadFSM.Instance.transform.position;
        Vector3 toTargetPosition = targetPosition - transform.position;

        m_RigidBody.AddForce(toTargetPosition.normalized, ForceMode2D.Impulse);
        m_RigidBody.velocity = Vector3.ClampMagnitude(m_RigidBody.velocity, toTargetPosition.magnitude * 3f);
        return(true);
    }
Beispiel #25
0
        /// <inheritdoc />
        public override void Execute(object parameter = null)
        {
            if (!CanExecute())
            {
                return;
            }

            IsExecuting = true;
            try
            {
                ExecuteMethod?.Invoke();
            }
            finally
            {
                IsExecuting = false;
            }
        }
Beispiel #26
0
    // 初期化処理など
    void Start()
    {
        // ターゲットのFPSを指定します
        Application.targetFrameRate = targetFps;
        Screen.sleepTimeout         = SleepTimeout.NeverSleep;
        if (isLowResolution)
        {
            Screen.SetResolution(Screen.width / 4, Screen.height / 4, true);
        }
        // デフォルト挙動セット
        this.executeMethod = this.defaultMode;
        Resources.FindObjectsOfTypeAll <UnityEngine.UI.Dropdown>()[0].value = (int)this.defaultMode;
        // ログファイル名指定
        BatteryLogger.Instance.LogFile = this.logFileName;

        // 操作対象のtransformの作成を行います
        transformArray = new Transform[objectNum];
        for (int i = 0; i < objectNum; ++i)
        {
            GameObject gmo = Object.Instantiate <GameObject>(prefab);
            transformArray[i] = gmo.transform;
        }


        // TransformJobの為に、TransformAccessArrayを事前に生成しておきます
        #region TRANSFORM_JOB
        transformAccessArray = new UnityEngine.Jobs.TransformAccessArray(objectNum, 0);
        for (int i = 0; i < objectNum; ++i)
        {
            transformAccessArray.Add(transformArray[i]);
        }
        #endregion TRANSFORM_JOB

        // 座標計算等を並行処理させるために、事前に計算用のワークを確保しておきます
        #region ARRAY_JOB
        myStructNativeArray = new Unity.Collections.NativeArray <MyStruct>(objectNum, Unity.Collections.Allocator.Persistent);
        #endregion ARRAY_JOB
    }
Beispiel #27
0
    public override void Execute()
    {
        // Re-initialisation of variables
        ExecuteMethod.OnceInUpdate("SquadChildFSM.UpdateLandmineList", null, null);
        Vector3 finalMovement = Vector3.zero;         // finalMovement: The final movement in which will be used for that current frame

        // if: There is no landmine, return the squad child to idle
        if (SquadChildFSM.ListLandmine.Count == 0)
        {
            m_scFSM.Advance(SCState.Idle);
            return;
        }

        // vectorApart: The distance between the current squad child cells and the current enemy child cells
        Vector3 smallestVectorApart = Vector3.one * 3f;
        Vector3 currentVectorApart;

        // for: Check every landmine and determines the closest landmine to avoid
        for (int i = 0; i < SquadChildFSM.ListLandmine.Count; i++)
        {
            currentVectorApart = m_scFSM.transform.position - SquadChildFSM.ListLandmine[i].transform.position;

            // if: The current distance between the enemy and child cells is smaller than the current smallest
            //     then use this new vector as the smallest
            if (currentVectorApart.magnitude < smallestVectorApart.magnitude)
            {
                smallestVectorApart = currentVectorApart;
            }
        }
        // finalMovement: The final vector to travel to avoid other cells
        finalMovement = smallestVectorApart.normalized * (1f - smallestVectorApart.magnitude / 3f);

        //Debug.Log(m_scFSM.gameObject.name + "::Rigibody->velocity(): " + m_scFSM.RigidBody.velocity + ", finalMovment: " + finalMovement);

        m_scFSM.RigidBody.AddForce(finalMovement * 10.0f);
        m_scFSM.RigidBody.velocity = Vector3.ClampMagnitude(m_scFSM.RigidBody.velocity, finalMovement.magnitude * 0.5f);
    }
Beispiel #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="exec">The execute method</param>
 /// <param name="canExecutePredicate">Predicate Function with object parameter</param>
 public DelegateCommand(ExecuteMethod exec, Func <object, bool> canExecutePredicate)
     : this(exec)
 {
     canExecute = canExecutePredicate;
 }
Beispiel #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand"/> class.
 /// </summary>
 /// <param name="exec">The execute method</param>
 public DelegateCommand(ExecuteMethod exec)
 {
     executeMethod = exec;
 }
Beispiel #30
0
        static void Main(string[] args)
        {

            ExecuteMethod timer = new ExecuteMethod(Message);
            timer(5);
        }
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="exec"></param>
 /// <param name="cmeth"></param>
 public DelegateCommand(ExecuteMethod exec)
 {
     _meth = exec;
 }
Beispiel #32
0
 protected internal ExecuteCommand(ExecuteMethod method)
 {
     this.method = method ?? (x => { });
     this.canExecuteFunc = x => method != null;
 }
 /// <summary>
 /// Returns true if the specified execute method option has been enabled.
 /// </summary>
 public virtual bool IsExecuteMethodSelected(ExecuteMethod method)
 {
     return(method == (executeMethods & method));
 }
Beispiel #34
0
 private void Execute(ExecuteMethod executeMethod)
 {
     if (IsExecuteMethodSelected(executeMethod))
     {
         Execute();
     }
 }
Beispiel #35
0
 // メニューで実行モードが変更された
 public void OnChangedSelection(int val)
 {
     executeMethod = (ExecuteMethod)val;
 }
Beispiel #36
0
    public override void Execute()
    {
        targetNutrients = m_scFSM.GetNearestResource();

        // if: The target nutrient is too close to the wall, disable the target
        if (targetNutrients != null)
        {
            if (Mathf.Abs(targetNutrients.transform.position.x) >= 4f)
            {
                targetNutrients = null;
            }
        }

        // Seperation Factor
        // vSeperationVector: The final vector used to space away from all the other nearby cells
        Vector3 vSeperationVector = Vector3.zero;

        Collider2D[] array_nearbyCollider = Physics2D.OverlapCircleAll(m_scFSM.transform.position, 0.5f, Constants.s_onlySquadChildLayer);

        if (array_nearbyCollider.Length > 0)
        {
            for (int i = 0; i < array_nearbyCollider.Length; i++)
            {
                // if: The current gameObject is itself
                if (array_nearbyCollider[i] == m_scFSM.gameObject)
                {
                    continue;
                }

                // vDirectionVector: The vector that the current squad child should be travelling in to space away from the current neighbour
                Vector3 vDirectionVector = (m_scFSM.transform.position - array_nearbyCollider[i].transform.position);

                // if: Somehow this is triggered, which is very often...
                if (vDirectionVector.magnitude > 0)
                {
                    vSeperationVector += vDirectionVector.normalized / vDirectionVector.sqrMagnitude;
                }
            }

            // Average the the final vector to use for spacing away
            vSeperationVector = vSeperationVector / array_nearbyCollider.Length;
            vSeperationVector = Vector3.ClampMagnitude(vSeperationVector, 7f);
        }

        // Attraction Factor
        ExecuteMethod.OnceInUpdate("SC_FindResourceState.RecalculateCenter", null, null);
        Vector3 vAttractionVector = vCenterPosition - m_scFSM.transform.position;

        vAttractionVector *= 10f;

        // Final Velocity Vector
        // toTargetVector: The vector between the target nutrients and the current squad child cells
        Vector3 toTargetVector;

        // if: There is no target nutrient, the find nutrients group will idle infront of squad group
        if (targetNutrients == null)
        {
            toTargetVector = PlayerSquadFSM.Instance.transform.position + new Vector3(0f, 2f, 0f) - m_scFSM.transform.position;
        }
        else
        {
            toTargetVector = targetNutrients.transform.position - m_scFSM.transform.position;
        }
        toTargetVector *= 10f;

        if (targetNutrients != null)
        {
            SquadChildFSM.Circle(targetNutrients.transform.position);
        }

        //Debug.Log("toTargetVector: " + toTargetVector.magnitude + ", vSeperationVector: " + vSeperationVector.magnitude + ", vAttractionVector: " + vAttractionVector.magnitude);

        // Apply vector to velocity

        /* Quick Vector Summary:
         * toTargetVector -> The vector between the nutrients and the 'FindResource' group
         * vSeperationVector -> The personal space vector
         * vAttractionVector -> The 'stay as a group' vector
         */
        m_scFSM.RigidBody.AddForce(toTargetVector + vSeperationVector + vAttractionVector * Time.deltaTime * 100f, ForceMode2D.Force);
        m_scFSM.RigidBody.velocity = Vector3.ClampMagnitude(m_scFSM.RigidBody.velocity, 3f);

        // if: The distance between the two bodies is less than a certain distance
        if (targetNutrients != null)
        {
            if (Vector3.Distance(targetNutrients.transform.position, m_scFSM.transform.position) < 0.5f)
            {
                // if: The current squad child is added to the nutrients
                if (targetNutrients.AddSquadChildCount())
                {
                    m_scFSM.Advance(SCState.Dead);
                    targetNutrients = null;
                }
            }
        }
    }
Beispiel #37
0
 public void CommandExecute(ProxyDbCommand command, TimeSpan duration, ExecuteMethod method, List<QueryExecutionPlan> executionPlan, object result = null)
 {
     _profileOutput.CommandExecute(command, duration, method, executionPlan, result);
 }
 protected void Execute(ExecuteMethod executeMethod)
 {
     if (IsExecuteMethodSelected(executeMethod))
     {
         Execute();
     }
 }
Beispiel #39
0
 public override void Exit()
 {
     ExecuteMethod.OnceInUpdate("SquadChildFSM.CalculateDefenceSheildOffset", null, null);
 }
 public MessageControl(ExecuteMethod method)
 {
     this.a_restService = method.ToString();
     this.a_restUrl = string.Format("{0}:{1}/{2}/", ConfigurationInfo.RestHost, ConfigurationInfo.RestPort, this.a_restService);
 }
 public RemoveCommand(ExecuteMethod <T> executeRemove, CanExecuteMethod <T> canExecuteRemove)
 {
     this.executeRemove    = executeRemove;
     this.canExecuteRemove = canExecuteRemove;
 }
 public void CommandExecute(ProxyDbCommand command, TimeSpan duration, ExecuteMethod method, List<QueryExecutionPlan> executionPlan, object result)
 {
     var commandMessage = new Van.Parys.Data.Common.CommandMessage(command.CommandText, duration, method.ToString(), command.ProxyDbConnection.Guid) {QueryExecutionPlans = executionPlan, NonReaderResult = result};
     Debug.WriteLine(commandMessage.ToString());
 }
Beispiel #43
0
 protected internal ExecuteCommand(ExecuteMethod method, Func<object, bool> canExecuteFunc)
     : this(method)
 {
     this.canExecuteFunc = canExecuteFunc ?? (x => true);
 }
 public void Execute(TParameter parameter)
 {
     ExecuteMethod?.Invoke(parameter);
 }
 /// <summary>
 /// Returns true if the specified execute method option has been enabled.
 /// </summary>
 public virtual bool IsExecuteMethodSelected(ExecuteMethod method)
 {
     return method == (executeMethods & method);
 }
 internal static void TestExecuteSourcesNoInput(string source, string baseline, string testname, ExecuteMethod method)
 {
     TestExecuteSourcesNoInput(new string[] { source }, baseline, testname, method);
 }