Example #1
0
 public ActionVector(E_Target target, float speedX, float speedY, float gravity, bool toLeft)
 {
     this.target = target;
     this.speedX = speedX;
     this.speedY = speedY;
     this.gravity = gravity;
     this.toLeft = toLeft;
 }
Example #2
0
 public ActionSingle2(E_Target targetRange, StageObjectType? targetType, string statusKey, string valueExpr, params string[] options)
 {
     this.targetRange = targetRange;
     this.targetType = targetType;
     this.statusKey = statusKey;
     this.valueExpr = valueExpr;
     this.options = options;
 }
Example #3
0
    public ActionSingle(E_Target target, E_Type type, float value, string[] param)
    {
        this.target = target;
        this.type = type;
        this.value = value;
        this.param = param;

        if (target == E_Target.Invalid || type == E_Type.Invalid)
        {
            Debug.LogError("args must be initilized: " + this);
        }
    }
Example #4
0
        static void ParseTarget(string str, out E_Target targetRange, out StageObjectType? targetType)
        {
            var tokens = str.Split('=');
            Assert.IsTrue(1 <= tokens.Length && tokens.Length <= 2);

            var result = EnumTool.Parse<E_Target>(tokens[0]);
            Assert.IsTrue(result != null, "invalid E_Target: " + tokens[0]);
            targetRange = result.Value;

            if (tokens.Length == 2)
            {
                targetType = EnumTool.Parse<StageObjectType>(tokens[1]);
            }
            else
            {
                targetType = null;
            }
        }
Example #5
0
    public IEnumerable<IActionHandler> FindTarget(E_Target target)
    {
        List<IActionHandler> ret = new List<IActionHandler>();

        if (target == E_Target.Self)
        {
            ret.Add(this as IActionHandler);
        }
        else if (target == E_Target.Contact)
        {
            foreach (var entity in Colliders)
            {
                if (entity is IActionHandler && !(entity is Projectile))
                {
                    ret.Add(entity as IActionHandler);
                }
            }
        }
        else if (target == E_Target.Forward)
        {
            ret.Add(Ahead as IActionHandler);
        }
        else if (target == E_Target.Puzzle)
        {
            if (this is HeroCharacter)
            {
                PuzzlePanel puzzlePanel = (this as HeroCharacter).puzzlePanel;
                if (puzzlePanel != null)
                {
                    ret.Add(puzzlePanel);
                }
            }
        }
        else if (target == E_Target.InScreen)
        {
            foreach (var entity in InScreenColliders)
            {
                ret.Add(entity as IActionHandler);
            }
        }
        else if (target == E_Target.User)
        {
            if (this is HeroCharacter)
            {
                ret.Add((this as HeroCharacter).user);
            }
        }
        else
        {
            Debug.LogError("not implemented");
        }
        return ret;
    }
Example #6
0
 public ActionDelegate(E_Target target, string actionPattern)
 {
     this.target = target;
     this.actionPattern = actionPattern;
 }
Example #7
0
 public ActionEffect(E_Target target, int effectId)
 {
     this.target = target;
     this.effectId = effectId;
 }
Example #8
0
    public IEnumerable<ActionHandler2> FindTarget(E_Target targetRange, StageObjectType? targetType)
    {
        IEnumerable<ActionHandler2> ret = null;

        // check range
        if (targetRange == E_Target.Self)
        {
            ret = ArrayTool.Create(this);
        }
        else if (targetRange == E_Target.Contact)
        {
            ret = Colliders.Select(x => x as ActionHandler2);
        }
        else if (targetRange == E_Target.Forward)
        {
            Assert.Fail("not implemented");
        }

        // check type
        if (targetRange != null)
        {
            ret = ret.Where(x => (x is StageObject) && (x as StageObject).stageObjectEntity.stageObjectType == targetType);
        }
        else
        {
            ret = ret.Where(x => (x is HeroCharacter) || (x is StageObject));
        }

        Assert.IsTrue(ret.All(x => x != null));
        return ret;
    }
Example #9
0
    ActionPattern(string text)
    {
        string contents = string.Empty;
        if (Parse(text, out patternType, out contents))
        {
            string[] tokens = Split(contents);
            if (patternType == ActionPatternType.Action)
            {
                if (tokens.Length < 3)
                {
                    throw new ArgumentException();
                }

                target = EnumTool.Parse<E_Target>(tokens[0]).Value;
                this.type = EnumTool.Parse<Action.E_Type>(tokens[1]).Value;
                //value = (float)CastTool.Parse("float", tokens[2]);
                //value = LuaVM.Instance.Calc(tokens[2]);
                //strValue = CalcRough(tokens[2]);
                strValue = tokens[2];
                if (tokens.Length > 3)
                {
                    for (int i = 3; i < tokens.Length; i++)
                    {
                        if (list == null)
                        {
                            list = new List<string>();
                        }
                        list.Add(tokens[i]);
                    }
                }
            }
            else if (patternType == ActionPatternType.Projectile)
            {
                if (tokens.Length != 2)
                {
                    throw new ArgumentException();
                }

                strValue = tokens[0];
                children = new List<ActionPattern>();
                children.Add(Create(tokens[1]));
            }
            else if (patternType == ActionPatternType.Delegate)
            {
                if (tokens.Length != 2)
                {
                    throw new ArgumentException();
                }

                target = EnumTool.Parse<E_Target>(tokens[0]).Value;
                strValue = tokens[1];
            }
            else if (patternType == ActionPatternType.Motion)
            {
                if (tokens.Length != 2)
                {
                    throw new ArgumentException();
                }

                strValue = tokens[0];
                children = new List<ActionPattern>();
                children.Add(Create(tokens[1]));
            }
            else if (patternType == ActionPatternType.Vector)
            {
                if (tokens.Length != 5)
                {
                    throw new ArgumentException();
                }

                target = EnumTool.Parse<E_Target>(tokens[0]).Value;
                list = new List<string>();
                list.Add(tokens[1]);
                list.Add(tokens[2]);
                list.Add(tokens[3]);
                list.Add(tokens[4]);
            }
            else
            {
                children = new List<ActionPattern>();
                foreach (var entity in Split(contents))
                {
                    children.Add(Create(entity));
                }
            }
        }
        else
        {
            throw new ArgumentException();
        }
    }