Ejemplo n.º 1
0
        /// <summary>
        /// The Figure_Compilation_Helper_Test.
        /// </summary>
        /// <param name="str">The str<see cref="IInstant"/>.</param>
        /// <param name="fom">The fom<see cref="FieldsAndPropertiesModel"/>.</param>
        /// <returns>The <see cref="IFigure"/>.</returns>
        private IFigure Figure_Compilation_Helper_Test(IInstant str, FieldsAndPropertiesModel fom)
        {
            IFigure rts = (IFigure)str.New();

            fom.Id = 202;
            rts[0] = 202;
            Assert.Equal(fom.Id, (rts)[0]);
            (rts)["Id"] = 404;
            Assert.NotEqual(fom.Id, (rts)[nameof(fom.Id)]);
            (rts)[nameof(fom.Name)] = fom.Name;
            Assert.Equal(fom.Name, (rts)[nameof(fom.Name)]);
            (rts).SerialCode = new Ussn(DateTime.Now.ToBinary());
            string hexTetra = (rts).SerialCode.ToString();
            Ussn   ssn      = new Ussn(hexTetra);

            Assert.Equal(ssn, (rts).SerialCode);

            for (int i = 1; i < str.Rubrics.Count; i++)
            {
                var r = str.Rubrics[i].RubricInfo;
                if (r.MemberType == MemberTypes.Field)
                {
                    var fi = fom.GetType().GetField(((FieldInfo)r).Name);
                    if (fi != null)
                    {
                        (rts)[r.Name] = fi.GetValue(fom);
                    }
                }
                if (r.MemberType == MemberTypes.Property)
                {
                    var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name);
                    if (pi != null)
                    {
                        (rts)[r.Name] = pi.GetValue(fom);
                    }
                }
            }

            for (int i = 1; i < str.Rubrics.Count; i++)
            {
                var r = str.Rubrics[i].RubricInfo;
                if (r.MemberType == MemberTypes.Field)
                {
                    var fi = fom.GetType().GetField(((FieldInfo)r).Name);
                    if (fi != null)
                    {
                        Assert.Equal((rts)[r.Name], fi.GetValue(fom));
                    }
                }
                if (r.MemberType == MemberTypes.Property)
                {
                    var pi = fom.GetType().GetProperty(((PropertyInfo)r).Name);
                    if (pi != null)
                    {
                        Assert.Equal((rts)[r.Name], pi.GetValue(fom));
                    }
                }
            }
            return(rts);
        }
Ejemplo n.º 2
0
        //check collisions with things
        public void CheckCollisions(World _world)
        {
            //float nearestLength = float.MaxValue;
            DrawRedFlash = false;
            List <List <GameObject> > objectsToCheck = ObjectManager.GetCellsOfRectangle(Bounds);

            foreach (List <GameObject> gameObjectList in objectsToCheck)
            {
                foreach (GameObject ob in gameObjectList)
                {
                    if (ob is Player)
                    {
                        continue;
                    }
                    if (ob == null)
                    {
                        //need to handle null exeception here
                        gameObjectList.Remove(ob);
                        continue;
                    }
                    if (ob.m_Bounds.Intersects(this.m_Bounds))
                    {
                        if (ob is IEnemy && m_PlayerState != PlayerState.Damaged)
                        {
                            IEnemy enemy = ob as IEnemy;
                            //get the amount of time that should be removed from the enemy and remove it from the player
                            TimeToDeath -= enemy.GetDamageAmount();
                            //do collision should take care of removing the enemy
                            enemy.DoCollision(this);
                            if (TimeToDeath.TotalSeconds <= 0)
                            {
                                m_PlayerState = PlayerState.Dead;
                                return;
                            }
                            m_PlayerState = PlayerState.Damaged;
                            DrawRedFlash  = true;
                            continue;
                        }
                        if (ob is PowerUp)
                        {
                            if (m_PowerupPickupSound != null)
                            {
                                m_PowerupPickupSound.Stop();
                                m_PowerupPickupSound.Dispose();
                            }
                            m_PowerupPickupSound = ((PowerUp)ob).GetPickupSound();
                            m_PowerupPickupSound.Play();
                            //cheat powerups will always be instant now
                            if (ob is CheatPowerUp)
                            {
                                CheatPowerUp temp = ob as CheatPowerUp;
                                if (temp.CheatEffect is IInstant)
                                {
                                    IInstant instantEffect = temp.CheatEffect as IInstant;
                                    instantEffect.GetInstantEffect(this);
                                    WeaponSlot1Magic = null;
                                }
                                else
                                {
                                    CheatPowerUp cheat = ob as CheatPowerUp;
                                    WeaponSlot1Magic = cheat;
                                }
                            }
                            if (ob is WeaponPowerUp)
                            {
                                if (m_Weapons.Count < 4)
                                {
                                    Weapon weapon = WeaponPowerUp.GetWeaponType((WeaponPowerUp)ob);
                                    weapon.LoadContent();
                                    m_Weapons.Add(weapon);
                                }
                            }
                            ObjectManager.RemoveObject(ob);
                        }
                    }
                }
            }
        }