Ejemplo n.º 1
0
        public SceneAction Duplicate()
        {
            var result = new SceneAction {
                Delay                 = Delay,
                CrowdDelay            = CrowdDelay,
                Angle                 = Angle,
                Speed                 = Speed,
                AngleOffset           = AngleOffset,
                SpeedOffset           = SpeedOffset,
                EnemyColor            = EnemyColor,
                Acted                 = Acted,
                EnterPosition         = new Vector2(EnterPosition.x, EnterPosition.y),
                ActionTime            = ActionTime,
                ActionHealthThreshold = ActionHealthThreshold,
                NextAction            = NextAction == null ? null : NextAction.Duplicate(),
                Patterns              = new List <BulletPattern>(),
                Health                = Health,
                ItemType              = ItemType,
                DropRate              = DropRate,
                ShooterPrefabName     = ShooterPrefabName,
                Children              = new List <SceneAction>(),
                RandomEnterPosition   = RandomEnterPosition,
                RandomColor           = RandomColor,
                RandXRange            = new Vector2(RandXRange.x, RandXRange.y),
                RandYRange            = new Vector2(RandYRange.x, RandYRange.y),
                ShootProbability      = ShootProbability,
                Shoots                = Shoots
            };

            foreach (var pattern in Patterns)
            {
                result.Patterns.Add(pattern.Duplicate());
            }

            foreach (var action in Children)
            {
                result.Children.Add(action.Duplicate());
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static void AddSequence(Scene scene, SceneAction action, int interval = 15, int number = 20, Vector2?intervalRange = null)
        {
            var startFrame = action.Delay;

            for (int i = 0; i < number; i++)
            {
                var newAction = action.Duplicate();
                newAction.Delay = startFrame;
                if (newAction.RandomEnterPosition)
                {
                    var xRange = newAction.RandXRange;
                    var yRange = newAction.RandYRange;
                    var randx  = Math.Abs(xRange.x - xRange.y) < 0.01 ? xRange.x :Random.Range(xRange.x, xRange.y);
                    var randy  = Math.Abs(yRange.x - yRange.y) < 0.01 ? yRange.x : Random.Range(yRange.x, yRange.y);
                    newAction.EnterPosition = new Vector2(randx, randy);
                }

                if (newAction.RandomColor)
                {
                    newAction.EnemyColor = _colors[Random.Range(0, 3)];
                }

                newAction.Shoots = Random.Range(0.0f, 1.0f) <= newAction.ShootProbability;

                scene.AddAction(newAction);
                if (intervalRange != null)
                {
                    var range = (Vector2)intervalRange;
                    startFrame += Random.Range((int)range.x, (int)range.y);
                }
                else
                {
                    startFrame += interval;
                }
            }
        }