Esempio n. 1
0
        private WabeFieldType CalculateFieldType(WabeType type, WabeDirection direction, int index)
        {
            if (index == 4)
            {
                return(WabeFieldType.Center);
            }
            if (0 != ((index + 1) & 1))
            {
                return(WabeFieldType.Unused);
            }
            switch (type)
            {
            case WabeType.TwoWabe:
                switch (direction)
                {
                case WabeDirection.Up | WabeDirection.Left:
                    return((0 == (index & 4)) ? WabeFieldType.Unused : WabeFieldType.Unpowered);

                case WabeDirection.Down | WabeDirection.Right:
                    return((0 != (index & 4)) ? WabeFieldType.Unused : WabeFieldType.Unpowered);

                case WabeDirection.Down | WabeDirection.Left:
                    return((0 != (index & 2)) ? WabeFieldType.Unused : WabeFieldType.Unpowered);

                case WabeDirection.Up | WabeDirection.Right:
                    return((0 == (index & 2)) ? WabeFieldType.Unused : WabeFieldType.Unpowered);
                }
                break;

            case WabeType.ThreeWabe:
                switch (direction)
                {
                case WabeDirection.Left:
                    return(index == 3 ? WabeFieldType.Unused : WabeFieldType.Unpowered);

                case WabeDirection.Right:
                    return(index == 5 ? WabeFieldType.Unused : WabeFieldType.Unpowered);

                case WabeDirection.Up:
                    return(index == 1 ? WabeFieldType.Unused : WabeFieldType.Unpowered);

                case WabeDirection.Down:
                    return(index == 7 ? WabeFieldType.Unused : WabeFieldType.Unpowered);
                }
                break;

            case WabeType.FourWabe:
                if (direction == WabeDirection.Mid)
                {
                    return(WabeFieldType.Unpowered);
                }
                break;
            }
            throw new ArgumentException("The given index or direction does not match any field type.", nameof(index));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Wabe"/> class.
        /// </summary>
        /// <param name="game">The game instance.</param>
        /// <param name="type">The wabe type.</param>
        /// <param name="x">The x position.</param>
        /// <param name="y">The y position.</param>
        /// <param name="size">The size of the wabe (Size, ScalingFactor).</param>
        /// <param name="resourceName">The resource name of the explosion sound</param>
        public Wabe(ChainReactGame game, WabeType type, int x, int y, float size, bool skipExplodeAnimation)
        {
            _skipAnimation = skipExplodeAnimation;
            _game          = game;
            Type           = type;
            Fields         = new WabeField[9];
            X = x;
            Y = y;

            Layout = new WabeLayout(this, new Vector2(0, 5));
            switch (Type)
            {
            case WabeType.FourWabe:
                SphereCount = 4;
                for (var i = 0; i <= 8; i++)
                {
                    Fields[i] = new WabeField(Layout.Fields[i], i);
                }
                break;

            case WabeType.ThreeWabe:
                SphereCount = 3;
                for (var i = 0; i <= 8; i++)
                {
                    Fields[i] = new WabeField(Layout.Fields[i], i);
                }
                break;

            case WabeType.TwoWabe:
                SphereCount = 2;
                for (var i = 0; i <= 8; i++)
                {
                    Fields[i] = new WabeField(Layout.Fields[i], i);
                }
                break;
            }
            _size = size;
            var sound = ResourceManager.TryGetResource <SoundEffect>("ExplosionSoundEffect");

            AnimationManager = new ExplosionManager(new List <Explosion>(), 3, sound)
            {
                AbsolutePosition = GetPositionOfWabeCenter(),
                IsRelative       = true
            };
            PopulateExplosionManager();
        }
Esempio n. 3
0
 private WabeFieldType CalculateFieldType(WabeType type, WabeDirection direction, int index)
 {
     if (index == 4) return WabeFieldType.Center;
     if (0 != ((index + 1) & 1)) return WabeFieldType.Unused;
     switch (type)
     {
         case WabeType.TwoWabe:
             switch (direction)
             {
                 case WabeDirection.Up | WabeDirection.Left:
                     return (0 == (index & 4)) ? WabeFieldType.Unused : WabeFieldType.Unpowered;
                 case WabeDirection.Down | WabeDirection.Right:
                     return (0 != (index & 4)) ? WabeFieldType.Unused : WabeFieldType.Unpowered;
                 case WabeDirection.Down | WabeDirection.Left:
                     return (0 != (index & 2)) ? WabeFieldType.Unused : WabeFieldType.Unpowered;
                 case WabeDirection.Up | WabeDirection.Right:
                     return (0 == (index & 2)) ? WabeFieldType.Unused : WabeFieldType.Unpowered;
             }
             break;
         case WabeType.ThreeWabe:
             switch (direction)
             {
                 case WabeDirection.Left:
                     return index == 3 ? WabeFieldType.Unused : WabeFieldType.Unpowered;
                 case WabeDirection.Right:
                     return index == 5 ? WabeFieldType.Unused : WabeFieldType.Unpowered;
                 case WabeDirection.Up:
                     return index == 1 ? WabeFieldType.Unused : WabeFieldType.Unpowered;
                 case WabeDirection.Down:
                     return index == 7 ? WabeFieldType.Unused : WabeFieldType.Unpowered;
             }
             break;
         case WabeType.FourWabe:
             if (direction == WabeDirection.Mid) return WabeFieldType.Unpowered;
             break;
     }
     throw new ArgumentException("The given index or direction does not match any field type.", nameof(index));
 }