예제 #1
0
    void die()
    {
        Destroy(gameObject);

        foreach (ResourceType type in EnumUtil.AllValues <ResourceType>())
        {
            for (int i = 0; i < ResourceProfile[type]; i++)
            {
                Vector3 explosion = Random.onUnitSphere * RandomExtra.Range(ParticleExplosiveForceRange);
                var     particle  = Instantiate(ParticlePrefab, transform.position, Quaternion.LookRotation(explosion));
                particle.Initialize(Player.Instance.transform, type);
                particle.Rigidbody.AddForce(explosion, ForceMode.VelocityChange);
            }
        }

        PlanetExplosionEffect.Instance.Play(transform.position);
    }
        private static IDictionary <string, TemplateCommandEnum> InitCommands()
        {
            var commands = new Dictionary <string, TemplateCommandEnum>();

            foreach (var tc in EnumUtil.AllValues <TemplateCommandEnum>())
            {
                var att = tc.GetAttribute <TemplateCommandNameAttribute>();
                if (att == null)
                {
                    continue;
                }
                foreach (var commandName in att.CommandNames)
                {
                    commands.Add(commandName, tc);
                }
            }
            return(commands);
        }
예제 #3
0
    void OnTriggerEnter(Collider other)
    {
        var currentResources = Player.Instance.Resources;
        var targetResources  = PillarOfCreation.Goals;

        bool won = true;

        foreach (ResourceType type in EnumUtil.AllValues <ResourceType>())
        {
            if (currentResources[type] < targetResources[type])
            {
                won = false;
                break;
            }
        }

        if (won)
        {
            SceneManager.LoadScene(SceneToLoadOnVictory);
        }
    }
        public static AbstractConditionPart Deserialize(string condition, IDictionary <string, AbstractConditionPart> dicConditionPart)
        {
            condition = condition.Trim();
            condition = ManageDelmitter(condition, dicConditionPart, "\"", "\"", x => new LiteralConditionPart {
                Value = x
            });                                                                                                                             // Literals
            condition = ManageDelmitter(condition, dicConditionPart, "{", "}", x => new VariableConditionPart {
                VariableName = x
            });                                                                                                                             // Variables
            condition = ManageDelmitter(condition, dicConditionPart, "(", ")", x => Deserialize(x, dicConditionPart));                      // Parantheses

            var dicOps = EnumUtil.AllValues <ConditionPartOperatorEnum>().Where(x => x.Priority() > 0).GroupBy(x => x.Priority()).ToDictionary(x => x.Key, x => x.ToArray());

            foreach (var grpOper in dicOps.Keys.OrderBy(x => x))
            {
                var operators = dicOps[grpOper];
                var allOps    = operators.SelectMany(x => x.GetAttribute <SupportedOperatorAttribute>().Operators.Select(o => new KeyValuePair <string, ConditionPartOperatorEnum>(o, x))).OrderBy(x => 0 - x.Key.Length);
                foreach (var o in allOps)
                {
                    var    isSequential = o.Value.GetAttribute <SequentialAttribute>() != null;
                    var    curOps       = o.Value.GetAttribute <SupportedOperatorAttribute>().Operators.OrderBy(x => 0 - x.Length).ToArray();
                    string op;
                    while ((op = FindFirstOper(condition, isSequential ? curOps : new [] { o.Key })) != null)
                    {
                        condition = DeserializeGroupOperator(condition, dicConditionPart, op, allOps.Select(x => x.Key).ToArray(), o.Value);
                    }
                }
            }

            condition = condition.Trim();

            if (condition.Contains(","))
            {
                var conditions = condition.Split(',').Select(x => x.Trim()).ToArray();
                return(new GroupedConditionPart {
                    Values = conditions.Select(x => dicConditionPart[x.InfoBetween("[", "]")])
                });
            }
            return(dicConditionPart[condition.InfoBetween("[", "]")]);
        }