Exemplo n.º 1
0
    public void generateTrigger(int materialIndex)
    {
        GameObject triggerObj = Instantiate(triggerPrefab) as GameObject;

        triggerObj.transform.SetParent(triggerRoot);
        triggerObj.transform.localPosition = new Vector3(Random.Range(-9f, 9f), 0f, Random.Range(-9f, 9f));
        triggerObj.layer = LayerMask.NameToLayer("Trigger" + cameraCtrl.justAddWorldId);
        triggerObj.transform.Find("Sphere").gameObject.layer         = LayerMask.NameToLayer("Trigger" + cameraCtrl.justAddWorldId);
        triggerObj.transform.Find("ParticleSystem").gameObject.layer = LayerMask.NameToLayer("Trigger" + cameraCtrl.justAddWorldId);
        //triggerObj.GetComponent<Renderer> ().sharedMaterial = allColorMaterials [materialIndex];
        triggerObj.transform.Find("Sphere").GetComponent <Renderer>().sharedMaterial = allColorMaterials [materialIndex];
        ParticleSystem ps = triggerObj.GetComponentInChildren <ParticleSystem> ();

        ParticleSystem.MainModule psmain = ps.main;
        psmain.startColor = allColorMaterials [materialIndex].color;
        TriggerItem trigger = triggerObj.GetComponent <TriggerItem> ();

        trigger.Init(cameraCtrl.justAddWorldId, materialIndex);

        // generate 5 obstacle at same time
        int randomNum = Random.Range(4, 7);

        for (int i = 0; i < randomNum; i++)
        {
            GameObject obstacle = blockGenerater.generateBlock(allColorMaterials[materialIndex]);
            trigger.addObstacle(obstacle);
        }
    }
Exemplo n.º 2
0
 public override async Task Execute(TriggerItem triggerItem)
 {
     var serviceDescription = new DeleteServiceDescription(triggerItem.Service.Properties.ServiceName)
     {
         ForceDelete = true
     };
     await _fabricClient.ServiceManager.DeleteServiceAsync(serviceDescription);
 }
        public override async Task Execute(TriggerItem triggerItem)
        {
            var serviceDescription = new StatelessServiceUpdateDescription()
            {
                InstanceCount = TargetNumInstances
            };

            await _fabricClient.ServiceManager.UpdateServiceAsync(triggerItem.Service.Properties.ServiceName, serviceDescription);
        }
Exemplo n.º 4
0
            /// <summary>
            /// Erzeugt ein TriggerItem aus einem XML-String
            /// </summary>
            /// <param name="Configuration"></param>
            /// <returns></returns>
            public static TriggerItem FromXML(string Configuration)
            {
                XmlSerializer ser    = new XmlSerializer(typeof(TriggerItem));
                TextReader    reader = new StringReader(Configuration);
                TriggerItem   result = (TriggerItem)ser.Deserialize(reader);

                reader.Close();
                return(result);
            }
Exemplo n.º 5
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Trigger"))
     {
         TriggerItem item = other.gameObject.GetComponent <TriggerItem>();
         if (item != null)
         {
             item.ColEnter(this);
         }
     }
 }
Exemplo n.º 6
0
        private static List <TabItem> GenerateTriggerTabs(TriggerItem triggerItem)
        {
            var generalTab = new TabItem
            {
                Header  = LocalisationHelper.GetString("TabHeader_GeneralTrigger", triggerItem.DisplayName),
                Content = new TriggerGeneralTabContent(new GeneralTriggerViewModel(triggerItem.DisplayName))
            };

            return(new List <TabItem> {
                generalTab
            });
        }
Exemplo n.º 7
0
        public ManagementSpecs()
        {
            _taskScheduler = new TaskScheduler();
            var triggerItem = new TriggerItem();

            triggerItem.Tag         = "Test";
            triggerItem.StartDate   = new DateTime(2018, 3, 28);
            triggerItem.EndDate     = new DateTime(2018, 3, 30);
            triggerItem.TriggerTime = new DateTime(2018, 3, 29, 9, 30, 0);
            triggerItem.OnTrigger  += new OnTriggerEventHandler(triggerItem_OnTrigger);
            triggerItem.Enabled     = true;
            _taskScheduler.AddTrigger(triggerItem);
        }
Exemplo n.º 8
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Trigger")
        {
            TriggerItem item = col.gameObject.GetComponent <TriggerItem> ();
            item.destroyRelatedObstacle();

            Destroy(col.gameObject);
            monsterGenerator.removeMonsterByWorld(item.matIndex);

            gameBoot.combineOnce(item.worldId, item.matIndex);
        }
    }
Exemplo n.º 9
0
        public override string Execute(TriggerItem triggerItem)
        {
            string leftValue  = LeftValue.GetValue(triggerItem);
            string rightValue = RightValue.GetValue(triggerItem);

            switch (Operator)
            {
            case ExpressionOperator.Equal:
            case ExpressionOperator.NotEqual:
                bool result = false;
                if (rightValue.StartsWith("*") && rightValue.EndsWith("*"))
                {
                    result = leftValue.Contains(rightValue.Substring(1, rightValue.Length - 2));
                }
                else if (rightValue.StartsWith("*"))
                {
                    result = leftValue.StartsWith(rightValue.Substring(1));
                }
                else if (rightValue.EndsWith("*"))
                {
                    result = leftValue.StartsWith(rightValue.Substring(0, rightValue.Length - 1));
                }
                else
                {
                    result = leftValue == rightValue;
                }
                result = (Operator == ExpressionOperator.Equal ? result : !result);
                return(result ? "1" : "0");

            case ExpressionOperator.Contains:
                return(leftValue.Contains(rightValue) ? "1" : "0");

            case ExpressionOperator.StartsWith:
                return(leftValue.StartsWith(rightValue) ? "1" : "0");

            case ExpressionOperator.EndsWith:
                return(leftValue.EndsWith(rightValue) ? "1" : "0");

            case ExpressionOperator.And:
                return(leftValue == "1" && rightValue == "1" ? "1" : "0");

            case ExpressionOperator.Or:
                return(leftValue == "1" || rightValue == "1" ? "1" : "0");

            default:
                return("0");
            }
        }
Exemplo n.º 10
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            other.gameObject.GetComponent <Enemy>().TakeDamage(damage);
        }

        if (other.gameObject.CompareTag("Trigger"))
        {
            TriggerItem item = other.gameObject.GetComponent <TriggerItem>();
            if (item != null)
            {
                item.ColEnter();
            }
        }
    }
Exemplo n.º 11
0
        public override async Task Execute(TriggerItem triggerItem)
        {
            var serviceInstances = await _fabricClient.QueryManager.GetReplicaListAsync(triggerItem.Partition.Properties.PartitionInformation.Id);

            TargetNumInstances = serviceInstances.Count + ScaleDeltaNumInstances;
            var maxNumInstances = MaxNumInstances;

            if (maxNumInstances == -1)
            {
                var nodes = await _fabricClient.QueryManager.GetNodeListAsync();

                maxNumInstances = nodes.Count;
            }
            TargetNumInstances = Math.Min(TargetNumInstances, maxNumInstances);
            await base.Execute(triggerItem);
        }
        public override int Execute(TriggerItem triggerItem)
        {
            int leftValue  = LeftValue.GetValue(triggerItem);
            int rightValue = RightValue.GetValue(triggerItem);

            switch (Operator)
            {
            case ExpressionOperator.Add:
                return(leftValue + rightValue);

            case ExpressionOperator.Subtract:
                return(leftValue - rightValue);

            case ExpressionOperator.Multiply:
                return(leftValue * rightValue);

            case ExpressionOperator.Divide:
                return(leftValue / rightValue);

            case ExpressionOperator.Equal:
                return(leftValue == rightValue ? 1 : 0);

            case ExpressionOperator.NotEqual:
                return(leftValue != rightValue ? 1 : 0);

            case ExpressionOperator.Larger:
                return(leftValue > rightValue ? 1 : 0);

            case ExpressionOperator.LargerOrEqual:
                return(leftValue >= rightValue ? 1 : 0);

            case ExpressionOperator.Smaller:
                return(leftValue < rightValue ? 1 : 0);

            case ExpressionOperator.SmallerOrEqual:
                return(leftValue <= rightValue ? 1 : 0);

            case ExpressionOperator.And:
                return((leftValue != 0) && (rightValue != 0) ? 1 : 0);

            case ExpressionOperator.Or:
                return((leftValue != 0) || (rightValue != 0) ? 1 : 0);

            default:
                return(0);
            }
        }
Exemplo n.º 13
0
    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Slate"))
        {
            this.transform.parent = null;
        }

        if (other.gameObject.CompareTag("CommandSlate"))
        {
            this.transform.parent = null;
            TriggerItem item = other.gameObject.GetComponent <TriggerItem>();
            if (item != null)
            {
                item.ColExit(this);
            }
        }
    }
Exemplo n.º 14
0
        /// <summary>
        /// 创建CronTrigger
        /// </summary>
        /// <returns></returns>
        public static ICronTrigger CreateCronTrigger(TriggerItem triggerItem)
        {
            TriggerBuilder triggerBuilder = TriggerBuilder.Create();

            if (!string.IsNullOrEmpty(triggerItem.StartTime))
            {
                triggerBuilder = triggerBuilder.StartAt(Convert.ToDateTime(triggerItem.StartTime));
            }
            if (!string.IsNullOrEmpty(triggerItem.EndTime))
            {
                triggerBuilder = triggerBuilder.EndAt(Convert.ToDateTime(triggerItem.EndTime));
            }
            triggerBuilder = triggerBuilder.WithCronSchedule(triggerItem.CronExpression);
            ICronTrigger trigger = (ICronTrigger)triggerBuilder
                                   .WithCronSchedule(triggerItem.CronExpression)
                                   .WithIdentity(triggerItem.Name, triggerItem.Group)
                                   .Build();

            return(trigger);
        }
Exemplo n.º 15
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Enemy") && _hurtEnable)
        {
            Hurt(other.gameObject.GetComponent <Enemy>().GetDamage());
        }

        if (other.gameObject.CompareTag("Depot1"))
        {
            PowerUp1();
        }

        if (other.gameObject.CompareTag("Depot2"))
        {
            PowerUp2();
        }

        if (other.gameObject.CompareTag("Trigger"))
        {
            TriggerItem item = other.gameObject.GetComponent <TriggerItem>();
            if (item != null)
            {
                item.ColEnter(this);
            }
        }

        if (other.gameObject.CompareTag("Slate"))
        {
            this.transform.parent = other.transform;
        }

        if (other.gameObject.CompareTag("CommandSlate"))
        {
            this.transform.parent = other.transform;
            TriggerItem item = other.gameObject.GetComponent <TriggerItem>();
            if (item != null)
            {
                item.ColEnter(this);
            }
        }
    }
Exemplo n.º 16
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {
            other.GetComponent <Enemy>().TakeDamage(damage);
        }

        if (other.gameObject.CompareTag("Ground") || other.gameObject.CompareTag("TwoWaysPlatform"))
        {
            Destroy(gameObject);
        }

        if (other.gameObject.CompareTag("Trigger"))
        {
            TriggerItem item = other.gameObject.GetComponent <TriggerItem>();
            if (item != null)
            {
                item.ColEnter();
            }
        }
    }
Exemplo n.º 17
0
        private List <TriggerItem> GatherMetricsFromSF()
        {
            var triggerItems = new List <TriggerItem>();

            foreach (var application in _root.Applications)
            {
                foreach (var service in application.Services)
                {
                    foreach (var partition in service.Partitions)
                    {
                        foreach (var replica in partition.Replicas)
                        {
                            var triggerItem = new TriggerItem()
                            {
                                Application = application,
                                Service     = service,
                                Partition   = partition,
                                Replica     = replica
                            };
                            foreach (var metricReport in replica.DeploymentDetails.ReportedLoad)
                            {
                                triggerItem.Metrics.Add(new TriggerItemMetric()
                                {
                                    Name            = metricReport.Name,
                                    Value           = metricReport.Value,
                                    LastReportedUtc = metricReport.LastReportedUtc
                                });
                            }
                            if (triggerItem.Metrics.Any())
                            {
                                triggerItems.Add(triggerItem);
                                WatchdogEventSource.Current.TriggerItemReceived(triggerItem.ToString());
                            }
                        }
                    }
                }
            }

            return(triggerItems);
        }
 public override string GetValue(TriggerItem triggerItem)
 {
     return(triggerItem != null ? triggerItem.Application.Properties.ApplicationName.AbsolutePath : null);
 }
 public int Add(TriggerItem value)
 {
     return (List.Add(value));
 }
Exemplo n.º 20
0
 public override string GetValue(TriggerItem triggerItem)
 {
     return(triggerItem != null ? triggerItem.Service.Properties.ServiceTypeName : null);
 }
Exemplo n.º 21
0
 public string ToString(TriggerItem triggerItem)
 {
     return($"{LeftValue.ToString(triggerItem)} {OperatorAsString(Operator)} {RightValue.ToString(triggerItem)}");
 }
Exemplo n.º 22
0
 public abstract TValue Execute(TriggerItem triggerItem);
Exemplo n.º 23
0
 public bool Contains(TriggerItem value)
 {
     return(List.Contains(value));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Fügt ein neues Trigger-Item hinzu
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public TriggerItem AddTrigger(TriggerItem item)
 {
     return(_triggerItems[_triggerItems.Add(item)]);
 }
 public OnTriggerEventArgs(TriggerItem item, DateTime triggerDate)
 {
     _item = item;
     _triggerDate = triggerDate;
 }
Exemplo n.º 26
0
 public void Remove(TriggerItem value)
 {
     List.Remove(value);
 }
 public bool Contains(TriggerItem value)
 {
     return (List.Contains(value));
 }
Exemplo n.º 28
0
        public override int GetValue(TriggerItem triggerItem)
        {
            var loadMetric = triggerItem.Metrics.Where(r => r.Name == _metricName).FirstOrDefault();

            return(loadMetric != null ? loadMetric.Value : 0);
        }
 public int IndexOf(TriggerItem value)
 {
     return (List.IndexOf(value));
 }
 public void Insert(int index, TriggerItem value)
 {
     List.Insert(index, value);
 }
 public void Remove(TriggerItem value)
 {
     List.Remove(value);
 }
Exemplo n.º 32
0
 public int Add(TriggerItem value)
 {
     return(List.Add(value));
 }
Exemplo n.º 33
0
 public int IndexOf(TriggerItem value)
 {
     return(List.IndexOf(value));
 }
Exemplo n.º 34
0
        public override string ToString(TriggerItem triggerItem)
        {
            var loadMetric = triggerItem.Metrics.Where(r => r.Name == _metricName).FirstOrDefault();

            return(loadMetric != null ? loadMetric.Value.ToString() : "<null>");
        }
Exemplo n.º 35
0
 public void Insert(int index, TriggerItem value)
 {
     List.Insert(index, value);
 }
Exemplo n.º 36
0
 public OnTriggerEventArgs(TriggerItem item, DateTime triggerDate)
 {
     _item        = item;
     _triggerDate = triggerDate;
 }
 public TriggerItem AddTrigger(TriggerItem item)
 {
     return _triggerItems[_triggerItems.Add(item)];
 }