Exemple #1
0
        private Wabe()
        {
            Fields = new WabeField[9];
            var sound = ResourceManager.TryGetResource <SoundEffect>("ExplosionSoundEffect");

            AnimationManager = new ExplosionManager(new List <Explosion>(), 3, sound)
            {
                AbsolutePosition = GetPositionOfWabeCenter(),
                IsRelative       = true
            };
            PopulateExplosionManager();
        }
Exemple #2
0
        public Vector2 ConvertWabeFieldToVector2(WabeField field)
        {
            var id = Array.IndexOf(Fields, field);
            var x  = 0;
            var y  = 0;

            switch (id)
            {
            case 0:
            case 3:
            case 6:
                x = 0;
                break;

            case 1:
            case 4:
            case 7:
                x = 1;
                break;

            case 2:
            case 5:
            case 8:
                x = 2;
                break;
            }
            switch (id)
            {
            case 0:
            case 1:
            case 2:
                y = 0;
                break;

            case 3:
            case 4:
            case 5:
                y = 1;
                break;

            case 6:
            case 7:
            case 8:
                y = 2;
                break;
            }
            return(new Vector2(x, y));
        }
Exemple #3
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();
        }
Exemple #4
0
        private WabeField GetNearestPowerableField(WabeField field)
        {
            var       lowestValue = Fields.Length;
            WabeField wabeResult  = null;

            foreach (var nearField in Fields.ToList())
            {
                if (nearField.Type == WabeFieldType.Unpowered)
                {
                    var val     = Math.Abs((nearField.Id - field.Id));
                    var row     = field.Id / 3;
                    var rowNear = nearField.Id / 3;
                    if (val < lowestValue || val == lowestValue && rowNear == row)
                    {
                        lowestValue = val;
                        wabeResult  = nearField;
                    }
                }
            }
            return(wabeResult != null ? Fields[wabeResult.Id] : null);
        }
Exemple #5
0
 public void Set(Player owner, WabeField field)
 {
     if (field == null)
     {
         return;
     }
     if (field.Type != WabeFieldType.Unpowered)
     {
         field = Fields.First(i => i.Type == WabeFieldType.Unpowered);
     }
     if (field != null)
     {
         field.Type = WabeFieldType.Powered;
     }
     if (Owner != owner)
     {
         Owner = owner;
     }
     if (_game.CheckWin())
     {
         return;
     }
     PoweredSpheres++;
 }
 private Texture2D SelectTextureFromField(WabeField field)
 {
     switch (field.Type)
     {
         case WabeFieldType.Unpowered:
             return ResourceManager.GetResource<Texture2D>("Unpowered");
         case WabeFieldType.Powered:
             return ResourceManager.GetResource<Texture2D>("Powered");
         case WabeFieldType.Unused:
         case WabeFieldType.Center:
             return ResourceManager.GetResource<Texture2D>("Unowned");
         default:
             return null;
     }
 }