Esempio n. 1
0
        public override void DrawGizmos(ModifierTypes modifier, Color color, float size)
        {
            switch (modifier)
            {
            case ModifierTypes.Twice:
                DrawDoubleShots(color, size);
                break;

            case ModifierTypes.Thrice:
                DrawTripleShots(color, size);
                break;

            case ModifierTypes.Area:
                DrawTripleShots(color, size);
                break;

            case ModifierTypes.Us:
                break;

            case ModifierTypes.You:
                break;

            default:
                DrawSingleShot(color, size);
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// return the mod based at the time of levelup for the ability at a given level (default to 30)
        /// </summary>
        /// <param name="ability"></param>
        /// <returns></returns>
        public int GetModLevelup(Abilities ability, int level = 30, ModifierTypes Mod = ModifierTypes.Skill)
        {
            int abilityValue;

            abilityValue = GetAbility(ability, level, Mod);
            return(GetMod(abilityValue));
        }
Esempio n. 3
0
        private string ConvertModifier(ModifierTypes type)
        {
            switch (type)
            {
            case ModifierTypes.Like:
                return(":");

            case ModifierTypes.Equals:
                return("=");

            case ModifierTypes.GreaterThan:
                return(">");

            case ModifierTypes.LessThan:
                return("<");

            case ModifierTypes.Add:
                return("+");

            case ModifierTypes.Subtract:
                return("-");

            case ModifierTypes.Multiply:
                return("*");

            case ModifierTypes.Divide:
                return("/");

            default:
                return(":");
            }
        }
Esempio n. 4
0
    public override void OnTriggerEnter(Collider other)
    {
        Agent agent = other.GetComponent <Agent>();

        if (agent == null)
        {
            return;
        }

        ModifierTypes agentId = agent.Attributes.RaceModifier;

        switch (agentId)
        {
        case ModifierTypes.None:
            agent.Collider.enabled = false;
            StartCoroutine(Respawn(agent, agent.lookingDirection));
            Debug.Log("Eres el jugador");
            break;

        case ModifierTypes.Water:
            break;

        case ModifierTypes.Fire:
            break;

        case ModifierTypes.Air:
            break;
        }
    }
Esempio n. 5
0
        public static Verb GetVerb(Agent agent, VerbTypes type, ModifierTypes modifier = ModifierTypes.None)
        {
            switch (type)
            {
            case VerbTypes.Walk:
                return(new Walk(modifier, agent));

            case VerbTypes.Jump:
                return(new Jump(modifier, agent));

            case VerbTypes.Roll:
                return(new Roll(modifier, agent));

            case VerbTypes.Teleport:
                return(new Teleport(modifier, agent));

            case VerbTypes.Strike:
                return(new Strike(modifier, agent));

            case VerbTypes.Shoot:
                return(new Shoot(modifier, agent));

            case VerbTypes.Protect:
                return(new Protect(modifier, agent));

            case VerbTypes.Throw:
                return(new Throw(modifier, agent));

            case VerbTypes.Invert:
                return(new Invert(modifier, agent));
            }
            return(null);
        }
Esempio n. 6
0
        public ModifierProfile GetProfile(ModifierTypes type)
        {
            switch (type)
            {
            case ModifierTypes.Fire:
                return(fire);

            case ModifierTypes.Water:
                return(water);

            case ModifierTypes.Air:
                return(air);

            case ModifierTypes.Twice:
                return(twice);

            case ModifierTypes.Thrice:
                return(thrice);

            case ModifierTypes.Area:
                return(area);

            case ModifierTypes.Me:
                return(me);

            case ModifierTypes.You:
                return(you);

            case ModifierTypes.Us:
                return(us);

            default:
                return(none);
            }
        }
Esempio n. 7
0
        private GameObject SpawnModifierItem(ModifierTypes modifier)
        {
            GameObject   modifierObject = Instantiate(modifierItemPrefab);
            ModifierItem modifierItem   = modifierObject.GetComponent <ModifierItem>();

            modifierItem.SetModifier(modifier);
            return(modifierObject);
        }
Esempio n. 8
0
        /// <summary>
        /// Constructs a new modifier parse tree.
        /// </summary>
        /// <param name="modifierType">The type of the modifier.</param>
        /// <param name="span">The location of the parse tree.</param>
        public Modifier(ModifierTypes modifierType, Span span) : base(TreeType.Modifier, span)
        {
            if ((modifierType & (modifierType - 1)) != 0 || modifierType < ModifierTypes.None || modifierType > ModifierTypes.Narrowing)
            {
                throw new ArgumentOutOfRangeException("modifierType");
            }

            _ModifierType = modifierType;
        }
Esempio n. 9
0
        void Selector(out SelectorTypes selectorType,
                      out ModifierTypes modifierType)
        {
            SelectorTypes type; ModifierTypes modifierResult;

            Expect(2);
            selectorType = SelectorTypes.Unknown;
            Modifier(out modifierResult);
            modifierType = modifierResult;
        }
Esempio n. 10
0
        /// <summary>
        /// Constructs a collection of modifiers.
        /// </summary>
        /// <param name="modifiers">The modifiers in the collection.</param>
        /// <param name="span">The location of the parse tree.</param>
        public ModifierCollection(IList <Modifier> modifiers, Span span) : base(TreeType.ModifierCollection, modifiers, span)
        {
            if (modifiers == null || modifiers.Count == 0)
            {
                throw new ArgumentException("ModifierCollection cannot be empty.");
            }

            foreach (Modifier Modifier in modifiers)
            {
                _ModifierTypes = _ModifierTypes | Modifier.ModifierType;
            }
        }
Esempio n. 11
0
 private string ConvertModifier(ModifierTypes type)
 {
     switch (type)
     {
         case ModifierTypes.GreaterThan:
             return ">";
         case ModifierTypes.LessThan:
             return "<";
         default:
             return ":";
     }
 }
Esempio n. 12
0
        private string ConvertModifier(ModifierTypes type)
        {
            switch (type)
            {
            case ModifierTypes.GreaterThan:
                return(">");

            case ModifierTypes.LessThan:
                return("<");

            default:
                return(":");
            }
        }
Esempio n. 13
0
        internal CameraValueModifier(CameraValueBase owner, CameraState state, ModifierTypes type, double amount, bool autoRemove, long autoRemoveDelay)
        {
            this.Owner           = owner;
            this.State           = state;
            this.Type            = type;
            this.Amount          = amount;
            this.AutoRemove      = autoRemove;
            this.AutoRemoveDelay = autoRemoveDelay;

            if (this.State != null)
            {
                this.Priority = this.State.Priority;
            }
            else
            {
                this.Priority = -1000000;
            }
        }
Esempio n. 14
0
    public void AddStatModifier(Stats stat, ModifierTypes modifierType, float value, float duration)
    {
        Debug.Log("AddStatModifier");
        switch (stat)
        {
        case Stats.health:
            if (modifierType == ModifierTypes.mult)
            {
                healthModifiersMult += value / 100f - 1f;
            }
            else if (modifierType == ModifierTypes.sum)
            {
                healthModifiersSum += value;
            }
            break;

        case Stats.strength:
            if (modifierType == ModifierTypes.mult)
            {
                strengthModifiersMult += value / 100f - 1f;
            }
            else if (modifierType == ModifierTypes.sum)
            {
                strengthModifiersSum += value;
            }
            break;

        case Stats.defense:
            if (modifierType == ModifierTypes.mult)
            {
                defenseModifiersMult += value / 100f - 1f;
            }
            else if (modifierType == ModifierTypes.sum)
            {
                defenseModifiersSum += value;
            }
            break;
        }

        if (duration > 0)
        {
            StartCoroutine(RemoveStatModifierAfterSomeTime(stat, modifierType, value, duration));
        }
    }
Esempio n. 15
0
    public TowerModifier(Modifier model)
    {
        modifierType = ModifierTypes.None;

        itemName = model.ItemName;
        itemCost = model.ItemCost;

        clipSizeModifier = model.Properties.ClipSizeModifier;
        clipDelayTimeModifier = model.Properties.ClipDelayTimeModifier;
        reloadRateModifier = model.Properties.ReloadRateModifier;
        numberOfTargetsModifier = model.Properties.NumberOfTargetsModifier;
        targetRadiusMultiplier = model.Properties.TargetRadiusMultiplier;

        projectileSpeedModifier = model.Properties.ProjectileSpeedModifier;
        hitSplashMultiplier = model.Properties.HitSplashMultiplier;
        hitPhysicalMultiplier = model.Properties.HitPhysicalMultiplier;
        splashRadiusModifier = model.Properties.SplashRadiusModifier;

        statusEffectChance = model.Properties.StatusEffectChanceMultiplier;
        statuseffectDuration = model.Properties.StatusEffectDurationModifier;
    }
Esempio n. 16
0
    private IEnumerator AddStatModifierAfterSomeTime(Stats stat, ModifierTypes modifierType, float value, float duration)
    {
        yield return(new WaitForSeconds(duration));

        switch (stat)
        {
        case Stats.health:
            if (modifierType == ModifierTypes.mult)
            {
                healthModifiersMult += value / 100f - 1f;
            }
            else if (modifierType == ModifierTypes.sum)
            {
                healthModifiersSum += value;
            }
            break;

        case Stats.strength:
            if (modifierType == ModifierTypes.mult)
            {
                strengthModifiersMult += value / 100f - 1f;
            }
            else if (modifierType == ModifierTypes.sum)
            {
                strengthModifiersSum += value;
            }
            break;

        case Stats.defense:
            if (modifierType == ModifierTypes.mult)
            {
                defenseModifiersMult += value / 100f - 1f;
            }
            else if (modifierType == ModifierTypes.sum)
            {
                defenseModifiersSum += value;
            }
            break;
        }
    }
Esempio n. 17
0
    public override void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <Agent>() == null)
        {
            return;
        }
        base.OnTriggerEnter(other);


        ModifierTypes AgentId = other.GetComponent <Agent>().Attributes.RaceModifier;
        GameObject    Agent   = other.gameObject;

        switch (AgentId)
        {
        case ModifierTypes.Air:

            Agent.GetComponent <Agent>().Damage(damage);
            Debug.Log("Eres Aire y te estoy haciendo daño");
            break;

        case ModifierTypes.Fire:

            Agent.GetComponent <Agent>().Damage(damage);
            Debug.Log("Eres Fuego y te daño");
            break;


        case ModifierTypes.Water:

            Debug.Log("Eres Agua y te dejo");
            break;

        case ModifierTypes.None:

            Agent.GetComponent <Agent>().Damage(damage);
            Debug.Log("Eres Nada y daño");
            break;
        }
    }
Esempio n. 18
0
 void Modifier(out ModifierTypes type)
 {
     type = ModifierTypes.Equals;
     if (la.kind == 37)
     {
         Get();
         type = ModifierTypes.Equals;
     }
     else if (la.kind == 38)
     {
         Get();
         type = ModifierTypes.LessThan;
     }
     else if (la.kind == 39)
     {
         Get();
         type = ModifierTypes.GreaterThan;
     }
     else
     {
         SynErr(51);
     }
 }
        internal CameraValueModifier(CameraValueBase owner,
                                     CameraState state,
                                     ModifierTypes type,
                                     double amount,
                                     bool autoRemove,
                                     long autoRemoveDelay)
        {
            Owner           = owner;
            State           = state;
            Type            = type;
            Amount          = amount;
            AutoRemove      = autoRemove;
            AutoRemoveDelay = autoRemoveDelay;

            if (State != null)
            {
                Priority = State.Priority;
            }
            else
            {
                Priority = -1000000;
            }
        }
Esempio n. 20
0
 private string ConvertModifier(ModifierTypes type)
 {
     switch (type)
     {
         case ModifierTypes.Like:
             return ":";
         case ModifierTypes.Equals:
             return "=";
         case ModifierTypes.GreaterThan:
             return ">";
         case ModifierTypes.LessThan:
             return "<";
         case ModifierTypes.Add:
             return "+";
         case ModifierTypes.Subtract:
             return "-";
         case ModifierTypes.Multiply:
             return "*";
         case ModifierTypes.Divide:
             return "/";
         default:
             return ":";
     }
 }
Esempio n. 21
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier, ExpressionTreeBase left) : this()
 {
     NodeType = field;
     Modifier = modifier;
     SetLeft( left );
 }
Esempio n. 22
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier) : this()
 {
     NodeType = field;
     Modifier = modifier;
 }
Esempio n. 23
0
 public void SetData(ModifierTypes type, float damage)
 {
     modifier    = type;
     this.damage = damage;
     SpawnType();
 }
Esempio n. 24
0
        /// <summary>
        /// return an ability at a given level (default to 30)
        /// </summary>
        /// <param name="ability"></param>
        /// <returns></returns>
        public int GetAbility(Abilities ability, int level = 30, ModifierTypes modifiers = ModifierTypes.All)
        {
            int result = 0;
            int tomeResult;
            int PriorLifeTomeResult;

            //base value
            if (modifiers.HasFlag(ModifierTypes.Base))
            {
                result += BaseStat[(int)ability];
            }

            //creation raises
            if (modifiers.HasFlag(ModifierTypes.CreationRaise))
            {
                result += BaseStatRaise[(int)ability];
            }

            //level up
            if (modifiers.HasFlag(ModifierTypes.LevelUp))
            {
                for (int i = 4; i <= level; i += 4)
                {
                    if (LevelUp[i - 1] == ability)
                    {
                        result++;
                    }
                }
            }

            //tomes
            tomeResult          = 0;
            PriorLifeTomeResult = 0;
            if (modifiers.HasFlag(ModifierTypes.Tome))
            {
                for (int i = MaxAbilityTomeBonus - 1; i >= 0; i -= 1)
                {
                    if (Tome[(int)ability, i] <= level && Tome[(int)ability, i] > 0)
                    {
                        for (int x = 0; x <= i; x++)
                        {
                            if (level >= Constant.MinTomeLevel[x])
                            {
                                tomeResult += 1;
                            }
                        }
                        break;
                    }
                }



                for (int i = 0; i < MaxAbilityTomeBonus; i++)
                {
                    if (PriorLifeTome[(int)ability, i] <= level && PriorLifeTome[(int)ability, i] > 0)
                    {
                        PriorLifeTomeResult = i + 1;
                    }
                }
            }
            if (PriorLifeTomeResult >= tomeResult)
            {
                result += PriorLifeTomeResult;
            }
            else
            {
                result += tomeResult;
            }

            //tomes modified for Skill Ranks
            tomeResult          = 0;
            PriorLifeTomeResult = 0;
            if (modifiers.HasFlag(ModifierTypes.TomeMod))
            {
                //tomes used at level do not get added till after level has been taken so can not be used for Skill Ranks
                for (int i = MaxAbilityTomeBonus - 1; i >= 0; i -= 1)
                {
                    if (Tome[(int)ability, i] < level && Tome[(int)ability, i] > 0)
                    {
                        for (int x = 0; x <= i; x++)
                        {
                            if (level >= Constant.MinTomeLevel[x])
                            {
                                tomeResult += 1;
                            }
                        }
                        break;
                    }
                }
                //tome for past life are added at begining of levelup.
                for (int i = 0; i < MaxAbilityTomeBonus; i++)
                {
                    if (PriorLifeTome[(int)ability, i] <= level && PriorLifeTome[(int)ability, i] > 0)
                    {
                        PriorLifeTomeResult = i + 1;
                    }
                }
            }
            if (PriorLifeTomeResult >= tomeResult)
            {
                result += PriorLifeTomeResult;
            }
            else
            {
                result += tomeResult;
            }

            //Feats
            //TODO: limit by supplied level
            if ((modifiers & ModifierTypes.Feat) == ModifierTypes.Feat)
            {
                result += Feat[(int)ability];
            }

            //Enhancements
            //TODO: limit by supplied level
            if ((modifiers & ModifierTypes.Enhancement) == ModifierTypes.Enhancement)
            {
                result += Enhancement[(int)ability];
            }

            //Destinies
            //TODO: limit by supplied level
            if ((modifiers & ModifierTypes.Destiny) == ModifierTypes.Destiny)
            {
                result += Destiny[(int)ability];
            }

            //Gear
            //TODO: limit by supplied level (do we need to limit gear by level? By MinLevels perhaps?)
            if ((modifiers & ModifierTypes.Gear) == ModifierTypes.Gear)
            {
                result += Gear[(int)ability];
            }

            return(result);
        }
Esempio n. 25
0
 public void OpenToChoose(ModifierTypes newModifier)
 {
     SetChoosingState(InventoryState.ChoosingModifier);
     targetModifier = newModifier;
     playerStateGUI.DiaryLog.text = targetModifier.ToString();
 }
Esempio n. 26
0
 public void ChangeModifierB(ModifierTypes modifier)
 {
     VerbB.SetModifier(modifier);
 }
Esempio n. 27
0
 public Shoot(ModifierTypes modifier, Agent agent) : base(modifier, agent)
 {
     Type             = VerbTypes.Shoot;
     projectilePrefab = (GameObject)Resources.Load(projectilePrefabName) as GameObject;
 }
Esempio n. 28
0
	void Selector(out SelectorTypes selectorType, 
out ModifierTypes modifierType) {
		SelectorTypes type; ModifierTypes modifierResult; 
		Expect(2);
		selectorType = SelectorTypes.Unknown; 
		Modifier(out modifierResult);
		modifierType = modifierResult; 
	}
        /// <summary>
        /// return an ability at a given level (default to 30)
        /// </summary>
        /// <param name="Skill"></param>
        /// <returns></returns>
        public Decimal GetSkill(Skills Skill, int level = 30, ModifierTypes modifiers = ModifierTypes.All)
        {
            Decimal result = 0;
            Decimal tomeResult;
            Decimal PriorLifeTomeResult;

            //Spent Points
            if (modifiers.HasFlag(ModifierTypes.Spent))
            {
                result += (Decimal)RanksSpent[(int)Skill, level - 1];
            }


            //Rank Points at level
            if (modifiers.HasFlag(ModifierTypes.Rank))
            {
                if (ClassSkills[(int)Skill, level - 1])
                {
                    result += (Decimal)RanksSpent[(int)Skill, level - 1];
                }
                else
                {
                    result += (Decimal)RanksSpent[(int)Skill, level - 1] / 2;
                }
            }
            //Rank Points Total
            if (modifiers.HasFlag(ModifierTypes.RankTotal))
            {
                for (int i = 0; i < level; ++i)
                {
                    if (ClassSkills[(int)Skill, i])
                    {
                        result += (Decimal)RanksSpent[(int)Skill, i];
                    }
                    else
                    {
                        result += (Decimal)RanksSpent[(int)Skill, i] / 2;
                    }
                }
            }



            //Ability
            if (modifiers.HasFlag(ModifierTypes.Ability))
            {
                CharacterAbilityClass.Abilities ability;

                ability = CharacterAbilityClass.Abilities.Strength;

                if (SkillsList[(int)Skill].AbilityModifier == "Strength")
                {
                    ability = CharacterAbilityClass.Abilities.Strength;
                }
                if (SkillsList[(int)Skill].AbilityModifier == "Dexterity")
                {
                    ability = CharacterAbilityClass.Abilities.Dexterity;
                }
                if (SkillsList[(int)Skill].AbilityModifier == "Constitution")
                {
                    ability = CharacterAbilityClass.Abilities.Constitution;
                }
                if (SkillsList[(int)Skill].AbilityModifier == "Intelligence")
                {
                    ability = CharacterAbilityClass.Abilities.Intelligence;
                }
                if (SkillsList[(int)Skill].AbilityModifier == "Wisdom")
                {
                    ability = CharacterAbilityClass.Abilities.Wisdom;
                }
                if (SkillsList[(int)Skill].AbilityModifier == "Charisma")
                {
                    ability = CharacterAbilityClass.Abilities.Charisma;
                }
                result += (Decimal)CharacterManagerClass.CharacterManager.CharacterAbility.GetModLevelup(ability, level);
            }

            //tomes
            tomeResult          = 0;
            PriorLifeTomeResult = 0;
            if (modifiers.HasFlag(ModifierTypes.Tome))
            {
                for (int i = MaxSkillTomeBonus - 1; i >= 0; i -= 1)
                {
                    if (Tome[(int)Skill, i] <= level && Tome[(int)Skill, i] > 0)
                    {
                        for (int x = 0; x <= i; x++)
                        {
                            if (level >= Constant.MinSkillTomeLevel[x])
                            {
                                tomeResult += 1;
                            }
                        }
                        break;
                    }
                }


                //for (int i = 0; i < MaxSkillTomeBonus; i++)
                //{
                //    if (Tome[(int)Skill, i] <= level && Tome[(int)Skill, i] > 0 && level <= Constant.MinSkillTomeLevel[i])
                //        tomeResult = i + 1;
                //}



                for (int i = 0; i < MaxSkillTomeBonus; i++)
                {
                    if (PriorLifeTome[(int)Skill, i] <= level && PriorLifeTome[(int)Skill, i] > 0)
                    {
                        PriorLifeTomeResult = i + 1;
                    }
                }
            }
            if (PriorLifeTomeResult >= tomeResult)
            {
                result += (Decimal)PriorLifeTomeResult;
            }
            else
            {
                result += (Decimal)tomeResult;
            }


            //Feats
            //TODO: limit by supplied level
            if ((modifiers & ModifierTypes.Feat) == ModifierTypes.Feat)
            {
                result += (Decimal)Feat[(int)Skill];
            }

            //Enhancements
            //TODO: limit by supplied level
            if ((modifiers & ModifierTypes.Enhancement) == ModifierTypes.Enhancement)
            {
                result += (Decimal)Enhancement[(int)Skill];
            }

            //Destinies
            //TODO: limit by supplied level
            if ((modifiers & ModifierTypes.Destiny) == ModifierTypes.Destiny)
            {
                result += (Decimal)Destiny[(int)Skill];
            }

            //Gear
            //TODO: limit by supplied level (do we need to limit gear by level? By MinLevels perhaps?)
            if ((modifiers & ModifierTypes.Gear) == ModifierTypes.Gear)
            {
                result += (Decimal)Gear[(int)Skill];
            }

            return(result);
        }
Esempio n. 30
0
 public Walk(ModifierTypes modifier, Agent agent) : base(modifier, agent)
 {
     Type = VerbTypes.Walk;
 }
Esempio n. 31
0
 public Throw(ModifierTypes modifier, Agent agent) : base(modifier, agent)
 {
     Type = VerbTypes.Throw;
 }
Esempio n. 32
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier) : this()
 {
     NodeType = field;
     Modifier = modifier;
 }
Esempio n. 33
0
	void Modifier(out ModifierTypes type) {
		type = ModifierTypes.Equals; 
		if (la.kind == 37) {
			Get();
			type = ModifierTypes.Equals; 
		} else if (la.kind == 38) {
			Get();
			type = ModifierTypes.LessThan; 
		} else if (la.kind == 39) {
			Get();
			type = ModifierTypes.GreaterThan; 
		} else SynErr(51);
	}
Esempio n. 34
0
	void Modifier(out ModifierTypes type) {
		type = ModifierTypes.Equals; 
		switch (la.kind) {
		case 17: {
			Get();
			type = ModifierTypes.Colon; 
			break;
		}
		case 38: {
			Get();
			type = ModifierTypes.Equals; 
			break;
		}
		case 34: {
			Get();
			type = ModifierTypes.Like; 
			break;
		}
		case 39: {
			Get();
			type = ModifierTypes.LessThan; 
			break;
		}
		case 40: {
			Get();
			type = ModifierTypes.GreaterThan; 
			break;
		}
		case 31: {
			Get();
			type = ModifierTypes.Multiply; 
			break;
		}
		case 41: {
			Get();
			type = ModifierTypes.Divide; 
			break;
		}
		case 42: {
			Get();
			type = ModifierTypes.Add; 
			break;
		}
		case 36: {
			Get();
			type = ModifierTypes.Subtract; 
			break;
		}
		default: SynErr(57); break;
		}
	}
Esempio n. 35
0
        /*
        public Expression CreateExpressionOld(object context)
        {
            LiteralExpression child = Child as LiteralExpression;
            ValueExpression valueChild = Child as ValueExpression;
            if (child == null && valueChild == null)
            {
                throw new Exception();
            }
            object value = child != null ? (object)child.Value : (object)valueChild.Value;
            Expression childExpression = Child.CreateExpression(Type);

            var getExpression = (GetExpression)Root;

            switch (Type)
            {
                case SelectorTypes.Domain:
                    getExpression.Domain = child.Value;
                    return null;
                case SelectorTypes.Notes:
                    Root.ContainsTextSearch = true;
                    return GetExpression<Mention>(x => x.Description.Contains(child.Value));
                case SelectorTypes.Subject:
                case SelectorTypes.Name:
                    Root.ContainsTextSearch = true;
                    return GetExpression<Mention>(x => x.Name == child.Value);
                case SelectorTypes.Unspecified:
                    Root.ContainsTextSearch = true;
                    return GetExpression<Mention>(x => (x.Name != null && x.Name.Contains(child.Value)) || (x.Description != null && x.Description.Contains(child.Value)));
                case SelectorTypes.Description:
                    return GetExpression<Mention>(x => x.Description.Contains(child.Value));
                case SelectorTypes.FromDate:
                    return Expression.GreaterThanOrEqual(GetExpression<Mention, DateTime>(x => x.Date), child.ConvertExpression<DateTime>());
                case SelectorTypes.Type:
                    return GetExpression<Mention>(x => x.Type == child.Value);
                case SelectorTypes.Id:
                    int id = (int)value;
                    return GetExpression<Mention>(x => x.Id == id);
                case SelectorTypes.Created:
                case SelectorTypes.Date:
                case SelectorTypes.On:
                {
                    var results = child.Convert<DateTime[]>("DateTimeRange");

                    Expression exp;

                    if (Type == SelectorTypes.Created)
                    {
                        exp = GetExpression<Mention, DateTime>(x => x.CreatedOn);
                    }
                    else
                    {
                        exp = GetExpression<Mention, DateTime>(x => x.Date); 
                    }

                    switch (Modifier)
                    {
                        case ModifierTypes.GreaterThan:
                            return Expression.GreaterThan(exp, Expression.Constant(results[1]));
                        case ModifierTypes.LessThan:
                            return Expression.LessThan(exp, Expression.Constant(results[0]));
                        default:
                            if (results[0] == results[1]) return Expression.Equal(exp, Expression.Constant(results[0]));
                            else return Expression.AndAlso(Expression.GreaterThanOrEqual(exp, Expression.Constant(results[0])), Expression.LessThan(exp, Expression.Constant(results[1])));
                    }
                }    

                case SelectorTypes.ToDate:
                case SelectorTypes.Until:
                
                    return Expression.LessThanOrEqual(GetExpression<Mention, DateTime>(x => x.Date), child.ConvertExpression<DateTime>());
                
                case SelectorTypes.Tag:
                
                    return CreateTagExpression(value, valueChild != null);
                

                
                case SelectorTypes.DataSource:
                    return Expression.Constant(false);
                    //return CreateDatasourceExpression(value, valueChild != null);

                case SelectorTypes.Theme:
                    return Expression.Constant(false);
                    //return CreatePhraseExpression(value, valueChild != null);

                case SelectorTypes.Influence:
                case SelectorTypes.KloutScore:
                case SelectorTypes.Followers:
                case SelectorTypes.Sentiment:
                {
                    double[] results = child.Convert<double[]>("Sentiment");
                    Expression exp = null;

                    switch(Type )
                    {
                        case SelectorTypes.Sentiment: exp = GetExpression<Mention, double>(x => x.Sentiment); break;
                    }

                    switch (Modifier)
                    {
                        case ModifierTypes.GreaterThan:
                            return Expression.GreaterThan(exp, Expression.Constant(results[1]));
                        case ModifierTypes.LessThan:
                            return Expression.LessThan(exp, Expression.Constant(results[0]));
                        default:
                            if (results[0] == results[1])
                            {
                                return Expression.Equal(exp, Expression.Constant(results[0]));
                            }
                            else
                            {
                                return Expression.AndAlso(Expression.GreaterThanOrEqual(exp, Expression.Constant(results[0])), Expression.LessThanOrEqual(exp, Expression.Constant(results[1])));
                            }
                    }
                }

                case SelectorTypes.InstanceType:
                case SelectorTypes.Hour:
                case SelectorTypes.Month:
                case SelectorTypes.Minute:
                case SelectorTypes.Year:
                case SelectorTypes.Day:
                {
                    var results = child.Convert<double[]>("NumberRange").Select(x => (int)x).ToArray();

                    Expression exp = null;

                    if (Type == SelectorTypes.Year)
                    {
                        exp = GetExpression<Mention, int>(x => x.Date.Year); 
                    }
                    else if (Type == SelectorTypes.Day)
                    {
                        exp = GetExpression<Mention, int>(x => x.Date.Day); 
                    }
                    else if (Type == SelectorTypes.Month)
                    {
                        exp = GetExpression<Mention, int>(x => x.Date.Month); 
                    }
                    else if (Type == SelectorTypes.Minute)
                    {
                        exp = GetExpression<Mention, int>(x => x.Date.Minute); 
                    }
                    else if (Type == SelectorTypes.Hour)
                    {
                        exp = GetExpression<Mention, int>(x => x.Date.Hour); 
                    }
                    
                    switch (Modifier)
                    {
                        case ModifierTypes.GreaterThan:
                            return Expression.GreaterThan(exp, Expression.Constant(results[1]));
                        case ModifierTypes.LessThan:
                            return Expression.LessThan(exp, Expression.Constant(results[0]));
                        default:
                            if (results[0] == results[1])
                            {
                                return Expression.Equal(exp, Expression.Constant(results[0]));
                            }
                            else
                            {
                                return Expression.AndAlso(Expression.GreaterThanOrEqual(exp, Expression.Constant(results[0])), Expression.LessThanOrEqual(exp, Expression.Constant(results[1])));
                            }
                    }
                }

                case SelectorTypes.TagCount:
                {
                    var results = child.Convert<double[]>("NumberRange").Select(x => (int)x).ToArray();
               
                    Expression exp;
                   
                    exp = GetExpression<Mention, int>(x => x.Tags.Count());
                    
                    switch (Modifier)
                    {
                        case ModifierTypes.GreaterThan:
                            return Expression.GreaterThan(exp, Expression.Constant(results[1]));
                        case ModifierTypes.LessThan:
                            return Expression.LessThan(exp, Expression.Constant(results[0]));
                        default:
                            return Expression.Equal(exp, Expression.Constant(results[0]));
                    }
                }

                default:
                    return Expression.Constant(true);
            }
        }*/



        internal void SetModifierType(ModifierTypes modifierType)
        {
            Modifier = modifierType;
        }
Esempio n. 36
0
 public bool IsOfType(ModifierTypes type)
 {
     return((_ModifierTypes & type) == type);
 }
Esempio n. 37
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier, ExpressionTreeBase left) : this()
 {
     NodeType = field;
     Modifier = modifier;
     SetLeft(left);
 }
Esempio n. 38
0
 public Protect(ModifierTypes modifier, Agent agent) : base(modifier, agent)
 {
     Type = VerbTypes.Teleport;
 }
Esempio n. 39
0
        /*
         * public Expression CreateExpressionOld(object context)
         * {
         *  LiteralExpression child = Child as LiteralExpression;
         *  ValueExpression valueChild = Child as ValueExpression;
         *  if (child == null && valueChild == null)
         *  {
         *      throw new Exception();
         *  }
         *  object value = child != null ? (object)child.Value : (object)valueChild.Value;
         *  Expression childExpression = Child.CreateExpression(Type);
         *
         *  var getExpression = (GetExpression)Root;
         *
         *  switch (Type)
         *  {
         *      case SelectorTypes.Domain:
         *          getExpression.Domain = child.Value;
         *          return null;
         *      case SelectorTypes.Notes:
         *          Root.ContainsTextSearch = true;
         *          return GetExpression<Mention>(x => x.Description.Contains(child.Value));
         *      case SelectorTypes.Subject:
         *      case SelectorTypes.Name:
         *          Root.ContainsTextSearch = true;
         *          return GetExpression<Mention>(x => x.Name == child.Value);
         *      case SelectorTypes.Unspecified:
         *          Root.ContainsTextSearch = true;
         *          return GetExpression<Mention>(x => (x.Name != null && x.Name.Contains(child.Value)) || (x.Description != null && x.Description.Contains(child.Value)));
         *      case SelectorTypes.Description:
         *          return GetExpression<Mention>(x => x.Description.Contains(child.Value));
         *      case SelectorTypes.FromDate:
         *          return Expression.GreaterThanOrEqual(GetExpression<Mention, DateTime>(x => x.Date), child.ConvertExpression<DateTime>());
         *      case SelectorTypes.Type:
         *          return GetExpression<Mention>(x => x.Type == child.Value);
         *      case SelectorTypes.Id:
         *          int id = (int)value;
         *          return GetExpression<Mention>(x => x.Id == id);
         *      case SelectorTypes.Created:
         *      case SelectorTypes.Date:
         *      case SelectorTypes.On:
         *      {
         *          var results = child.Convert<DateTime[]>("DateTimeRange");
         *
         *          Expression exp;
         *
         *          if (Type == SelectorTypes.Created)
         *          {
         *              exp = GetExpression<Mention, DateTime>(x => x.CreatedOn);
         *          }
         *          else
         *          {
         *              exp = GetExpression<Mention, DateTime>(x => x.Date);
         *          }
         *
         *          switch (Modifier)
         *          {
         *              case ModifierTypes.GreaterThan:
         *                  return Expression.GreaterThan(exp, Expression.Constant(results[1]));
         *              case ModifierTypes.LessThan:
         *                  return Expression.LessThan(exp, Expression.Constant(results[0]));
         *              default:
         *                  if (results[0] == results[1]) return Expression.Equal(exp, Expression.Constant(results[0]));
         *                  else return Expression.AndAlso(Expression.GreaterThanOrEqual(exp, Expression.Constant(results[0])), Expression.LessThan(exp, Expression.Constant(results[1])));
         *          }
         *      }
         *
         *      case SelectorTypes.ToDate:
         *      case SelectorTypes.Until:
         *
         *          return Expression.LessThanOrEqual(GetExpression<Mention, DateTime>(x => x.Date), child.ConvertExpression<DateTime>());
         *
         *      case SelectorTypes.Tag:
         *
         *          return CreateTagExpression(value, valueChild != null);
         *
         *
         *
         *      case SelectorTypes.DataSource:
         *          return Expression.Constant(false);
         *          //return CreateDatasourceExpression(value, valueChild != null);
         *
         *      case SelectorTypes.Theme:
         *          return Expression.Constant(false);
         *          //return CreatePhraseExpression(value, valueChild != null);
         *
         *      case SelectorTypes.Influence:
         *      case SelectorTypes.KloutScore:
         *      case SelectorTypes.Followers:
         *      case SelectorTypes.Sentiment:
         *      {
         *          double[] results = child.Convert<double[]>("Sentiment");
         *          Expression exp = null;
         *
         *          switch(Type )
         *          {
         *              case SelectorTypes.Sentiment: exp = GetExpression<Mention, double>(x => x.Sentiment); break;
         *          }
         *
         *          switch (Modifier)
         *          {
         *              case ModifierTypes.GreaterThan:
         *                  return Expression.GreaterThan(exp, Expression.Constant(results[1]));
         *              case ModifierTypes.LessThan:
         *                  return Expression.LessThan(exp, Expression.Constant(results[0]));
         *              default:
         *                  if (results[0] == results[1])
         *                  {
         *                      return Expression.Equal(exp, Expression.Constant(results[0]));
         *                  }
         *                  else
         *                  {
         *                      return Expression.AndAlso(Expression.GreaterThanOrEqual(exp, Expression.Constant(results[0])), Expression.LessThanOrEqual(exp, Expression.Constant(results[1])));
         *                  }
         *          }
         *      }
         *
         *      case SelectorTypes.InstanceType:
         *      case SelectorTypes.Hour:
         *      case SelectorTypes.Month:
         *      case SelectorTypes.Minute:
         *      case SelectorTypes.Year:
         *      case SelectorTypes.Day:
         *      {
         *          var results = child.Convert<double[]>("NumberRange").Select(x => (int)x).ToArray();
         *
         *          Expression exp = null;
         *
         *          if (Type == SelectorTypes.Year)
         *          {
         *              exp = GetExpression<Mention, int>(x => x.Date.Year);
         *          }
         *          else if (Type == SelectorTypes.Day)
         *          {
         *              exp = GetExpression<Mention, int>(x => x.Date.Day);
         *          }
         *          else if (Type == SelectorTypes.Month)
         *          {
         *              exp = GetExpression<Mention, int>(x => x.Date.Month);
         *          }
         *          else if (Type == SelectorTypes.Minute)
         *          {
         *              exp = GetExpression<Mention, int>(x => x.Date.Minute);
         *          }
         *          else if (Type == SelectorTypes.Hour)
         *          {
         *              exp = GetExpression<Mention, int>(x => x.Date.Hour);
         *          }
         *
         *          switch (Modifier)
         *          {
         *              case ModifierTypes.GreaterThan:
         *                  return Expression.GreaterThan(exp, Expression.Constant(results[1]));
         *              case ModifierTypes.LessThan:
         *                  return Expression.LessThan(exp, Expression.Constant(results[0]));
         *              default:
         *                  if (results[0] == results[1])
         *                  {
         *                      return Expression.Equal(exp, Expression.Constant(results[0]));
         *                  }
         *                  else
         *                  {
         *                      return Expression.AndAlso(Expression.GreaterThanOrEqual(exp, Expression.Constant(results[0])), Expression.LessThanOrEqual(exp, Expression.Constant(results[1])));
         *                  }
         *          }
         *      }
         *
         *      case SelectorTypes.TagCount:
         *      {
         *          var results = child.Convert<double[]>("NumberRange").Select(x => (int)x).ToArray();
         *
         *          Expression exp;
         *
         *          exp = GetExpression<Mention, int>(x => x.Tags.Count());
         *
         *          switch (Modifier)
         *          {
         *              case ModifierTypes.GreaterThan:
         *                  return Expression.GreaterThan(exp, Expression.Constant(results[1]));
         *              case ModifierTypes.LessThan:
         *                  return Expression.LessThan(exp, Expression.Constant(results[0]));
         *              default:
         *                  return Expression.Equal(exp, Expression.Constant(results[0]));
         *          }
         *      }
         *
         *      default:
         *          return Expression.Constant(true);
         *  }
         * }*/



        internal void SetModifierType(ModifierTypes modifierType)
        {
            Modifier = modifierType;
        }
Esempio n. 40
0
 public SelectorExpression(SelectorTypes field, ModifierTypes modifier)
 {
     Field = field;
     Modifier = modifier;
 }