コード例 #1
0
ファイル: UserService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddUser( Rock.Models.Cms.User User )
        {
            if ( User.Guid == Guid.Empty )
                User.Guid = Guid.NewGuid();

            _repository.Add( User );
        }
コード例 #2
0
        public void Move( string id, Rock.CMS.DTO.BlockInstance BlockInstance )
        {
            var currentUser = Rock.CMS.UserService.GetCurrentUser();
            if ( currentUser == null )
                throw new WebFaultException<string>( "Must be logged in", System.Net.HttpStatusCode.Forbidden );

            using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() )
            {
                uow.objectContext.Configuration.ProxyCreationEnabled = false;
                Rock.CMS.BlockInstanceService BlockInstanceService = new Rock.CMS.BlockInstanceService();
                Rock.CMS.BlockInstance existingBlockInstance = BlockInstanceService.Get( int.Parse( id ) );

                if ( existingBlockInstance.Authorized( "Edit", currentUser ) )
                {
                    // If the block was moved from or to the layout section, then all the pages
                    // that use that layout need to be flushed from cache
                    if ( existingBlockInstance.Layout != BlockInstance.Layout )
                    {
                        if ( existingBlockInstance.Layout != null )
                            Rock.Web.Cache.Page.FlushLayout( existingBlockInstance.Layout );
                        if ( BlockInstance.Layout != null )
                            Rock.Web.Cache.Page.FlushLayout( BlockInstance.Layout );
                    }

                    uow.objectContext.Entry( existingBlockInstance ).CurrentValues.SetValues( BlockInstance );
                    BlockInstanceService.Move( existingBlockInstance );
                    BlockInstanceService.Save( existingBlockInstance, currentUser.PersonId );
                }
                else
                    throw new WebFaultException<string>( "Not Authorized to Edit this BlockInstance", System.Net.HttpStatusCode.Forbidden );
            }
        }
コード例 #3
0
        public void AddEntityChange( Rock.Models.Core.EntityChange EntityChange )
        {
            if ( EntityChange.Guid == Guid.Empty )
                EntityChange.Guid = Guid.NewGuid();

            _repository.Add( EntityChange );
        }
コード例 #4
0
ファイル: TemplateList.ascx.cs プロジェクト: Ganon11/Rock
        /// <summary>
        /// Handles the Delete event of the gCommunication control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gCommunication_Delete( object sender, Rock.Web.UI.Controls.RowEventArgs e )
        {
            var rockContext = new RockContext();
            var service = new CommunicationTemplateService( rockContext );
            var template = service.Get( e.RowKeyId );
            if ( template != null )
            {
                if ( !template.IsAuthorized( Authorization.EDIT, this.CurrentPerson ) )
                {
                    maGridWarning.Show( "You are not authorized to delete this template", ModalAlertType.Information );
                    return;
                }

                string errorMessage;
                if ( !service.CanDelete( template, out errorMessage ) )
                {
                    maGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                service.Delete( template );

                rockContext.SaveChanges();
            }

            BindGrid();
        }
コード例 #5
0
    public Sprite GetChunkSprite(Rock.RockType rockType)
    {
        Sprite chunkSprite = new Sprite();
        int randomSharpSelection = Random.Range(0, sharpChunks.Length);
        int randomHexSelection = Random.Range(0, hexChunks.Length);
        int randomTubeSelection = Random.Range(0, tubeChunks.Length);

        switch (rockType)
        {
            case Rock.RockType.sharp:
                chunkSprite = sharpChunks[randomSharpSelection];
                break;
            case Rock.RockType.hex:
                chunkSprite = hexSprites[randomHexSelection];
                break;
            case Rock.RockType.tube:
                chunkSprite = tubeChunks[randomTubeSelection];
                break;
            default:
                chunkSprite = sharpChunks[randomSharpSelection];
                break;
        }

        return chunkSprite;
    }
コード例 #6
0
ファイル: PersonService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddPerson( Rock.Models.Crm.Person Person )
        {
            if ( Person.Guid == Guid.Empty )
                Person.Guid = Guid.NewGuid();

            _repository.Add( Person );
        }
コード例 #7
0
        public void AddAttribute( Rock.Models.Core.Attribute Attribute )
        {
            if ( Attribute.Guid == Guid.Empty )
                Attribute.Guid = Guid.NewGuid();

            _repository.Add( Attribute );
        }
コード例 #8
0
        public void AddGroupType( Rock.Models.Groups.GroupType GroupType )
        {
            if ( GroupType.Guid == Guid.Empty )
                GroupType.Guid = Guid.NewGuid();

            _repository.Add( GroupType );
        }
コード例 #9
0
ファイル: PageService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddPage( Rock.Models.Cms.Page Page )
        {
            if ( Page.Guid == Guid.Empty )
                Page.Guid = Guid.NewGuid();

            _repository.Add( Page );
        }
コード例 #10
0
        public void AddBlogPostComment( Rock.Models.Cms.BlogPostComment BlogPostComment )
        {
            if ( BlogPostComment.Guid == Guid.Empty )
                BlogPostComment.Guid = Guid.NewGuid();

            _repository.Add( BlogPostComment );
        }
コード例 #11
0
        public void AddBlockInstance( Rock.Models.Cms.BlockInstance BlockInstance )
        {
            if ( BlockInstance.Guid == Guid.Empty )
                BlockInstance.Guid = Guid.NewGuid();

            _repository.Add( BlockInstance );
        }
コード例 #12
0
ファイル: RoleService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddRole( Rock.Models.Cms.Role Role )
        {
            if ( Role.Guid == Guid.Empty )
                Role.Guid = Guid.NewGuid();

            _repository.Add( Role );
        }
コード例 #13
0
        public void AddFieldType( Rock.Models.Core.FieldType FieldType )
        {
            if ( FieldType.Guid == Guid.Empty )
                FieldType.Guid = Guid.NewGuid();

            _repository.Add( FieldType );
        }
コード例 #14
0
ファイル: LayoutList.ascx.cs プロジェクト: pkdevbox/Rock
        /// <summary>
        /// Handles the Click event of the DeleteLayout control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void DeleteLayout_Click( object sender, Rock.Web.UI.Controls.RowEventArgs e )
        {
            RockTransactionScope.WrapTransaction( () =>
            {
                LayoutService layoutService = new LayoutService();
                Layout layout = layoutService.Get( e.RowKeyId );
                if ( layout != null )
                {
                    string errorMessage;
                    if ( !layoutService.CanDelete( layout, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    int siteId = layout.SiteId;

                    layoutService.Delete( layout, CurrentPersonId );
                    layoutService.Save( layout, CurrentPersonId );

                    LayoutCache.Flush( e.RowKeyId );
                }
            } );

            BindLayoutsGrid();
        }
コード例 #15
0
ファイル: ServiceObjects.cs プロジェクト: pkdevbox/Rock
        /// <summary>
        /// Geocodes the specified address.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="result">The ServiceObjects result.</param>
        /// <returns>
        /// True/False value of whether the address was standardized succesfully
        /// </returns>
        public override bool Geocode( Rock.Model.Location location, out string result )
        {
            if ( location != null )
            {
                string licenseKey = GetAttributeValue("LicenseKey");

                var client = new DOTSGeoCoderSoapClient();
                Location_V3 location_match = client.GetBestMatch_V3(
                    string.Format("{0} {1}",
                        location.Street1,
                        location.Street2),
                    location.City,
                    location.State,
                    location.Zip,
                    licenseKey );

                result = location_match.Level;

                if ( location_match.Level == "S" || location_match.Level == "P" )
                {
                    double latitude = double.Parse( location_match.Latitude );
                    double longitude = double.Parse( location_match.Longitude );
                    location.SetLocationPointFromLatLong(latitude, longitude);

                    return true;
                }
            }
            else
                result = "Null Address";

            return false;
        }
コード例 #16
0
ファイル: ServiceObjects.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Geocodes the specified address.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="resultMsg">The result MSG.</param>
        /// <returns>
        /// True/False value of whether the address was geocoded successfully
        /// </returns>
        public override VerificationResult Verify( Rock.Model.Location location, out string resultMsg )
        {
            VerificationResult result = VerificationResult.None;
            resultMsg = string.Empty;

            string licenseKey = GetAttributeValue("LicenseKey");

            var client = new DOTSGeoCoderSoapClient();
            Location_V3 location_match = client.GetBestMatch_V3(
                string.Format("{0} {1}",
                    location.Street1,
                    location.Street2),
                location.City,
                location.State,
                location.PostalCode,
                licenseKey );

            resultMsg = location_match.Level;

            if ( location_match.Level == "S" || location_match.Level == "P" )
            {
                double latitude = double.Parse( location_match.Latitude );
                double longitude = double.Parse( location_match.Longitude );
                if ( location.SetLocationPointFromLatLong( latitude, longitude ) )
                {
                    result = VerificationResult.Geocoded;
                }
            }

            return result;
        }
コード例 #17
0
        public static void AddPersonToFamily( Rock.Client.Person person, int childAdultRoleMemberId, int toFamilyId, bool removeFromOtherFamilies, HttpRequest.RequestResult result )
        {
            // setup the oData. childAdultRoleMemberId describes whether this person should be an adult or child in the family.
            string oDataFilter = string.Format( "?personId={0}&familyId={1}&groupRoleId={2}&removeFromOtherFamilies={3}", person.Id, toFamilyId, childAdultRoleMemberId, removeFromOtherFamilies );

            RockApi.Post_People_AddExistingPersonToFamily( oDataFilter, result );
        }
コード例 #18
0
ファイル: SiteService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddSite( Rock.Models.Cms.Site Site )
        {
            if ( Site.Guid == Guid.Empty )
                Site.Guid = Guid.NewGuid();

            _repository.Add( Site );
        }
コード例 #19
0
ファイル: BlockService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddBlock( Rock.Models.Cms.Block Block )
        {
            if ( Block.Guid == Guid.Empty )
                Block.Guid = Guid.NewGuid();

            _repository.Add( Block );
        }
コード例 #20
0
ファイル: LocationItemPicker.cs プロジェクト: NewSpring/Rock
        /// <summary>
        /// Sets the value.
        /// </summary>
        /// <param name="location">The location.</param>
        public void SetValue( Rock.Model.Location location )
        {
            if ( location != null )
            {
                ItemId = location.Id.ToString();
                List<int> parentLocationIds = new List<int>();
                var parentLocation = location.ParentLocation;

                while ( parentLocation != null )
                {
                    if ( parentLocationIds.Contains( parentLocation.Id ) )
                    {
                        // infinite recursion
                        break;
                    }

                    parentLocationIds.Insert( 0, parentLocation.Id ); ;
                    parentLocation = parentLocation.ParentLocation;
                }

                InitialItemParentIds = parentLocationIds.AsDelimited( "," );
                ItemName = location.ToString();
            }
            else
            {
                ItemId = Constants.None.IdValue;
                ItemName = Constants.None.TextHtml;
            }
        }
コード例 #21
0
ファイル: BusinessList.ascx.cs プロジェクト: NewPointe/Rockit
 /// <summary>
 /// Handles the RowSelected event of the gBusinessList control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
 protected void gBusinessList_RowSelected( object sender, Rock.Web.UI.Controls.RowEventArgs e )
 {
     var parms = new Dictionary<string, string>();
     var businessId = e.RowKeyId;
     parms.Add( "businessId", businessId.ToString() );
     NavigateToLinkedPage( "DetailPage", parms );
 }
コード例 #22
0
        public void AddDefinedType( Rock.Models.Core.DefinedType DefinedType )
        {
            if ( DefinedType.Guid == Guid.Empty )
                DefinedType.Guid = Guid.NewGuid();

            _repository.Add( DefinedType );
        }
コード例 #23
0
ファイル: FieldTypeCache.cs プロジェクト: jh2mhs8/Rock-ChMS
        /// <summary>
        /// Copies the model.
        /// </summary>
        /// <param name="fieldTypeModel">The field type model.</param>
        /// <returns></returns>
        public static FieldTypeCache CopyModel( Rock.Model.FieldType fieldTypeModel )
        {
            FieldTypeCache fieldType = new FieldTypeCache( fieldTypeModel );
            fieldType.Field = Rock.Field.Helper.InstantiateFieldType( fieldType.Assembly, fieldType.Class );

            return fieldType;
        }
コード例 #24
0
        /// <summary>
        /// Gets the HTML preview.
        /// </summary>
        /// <param name="communication">The communication.</param>
        /// <param name="person">The person.</param>
        /// <returns></returns>
        public override string GetHtmlPreview( Rock.Model.Communication communication, Person person )
        {
            var rockContext = new RockContext();

            // Requery the Communication object
            communication = new CommunicationService( rockContext ).Get( communication.Id );

            var globalAttributes = Rock.Web.Cache.GlobalAttributesCache.Read();
            var mergeValues = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( null );

            if ( person != null )
            {
                mergeValues.Add( "Person", person );

                var recipient = communication.Recipients.Where( r => r.PersonAlias != null && r.PersonAlias.PersonId == person.Id ).FirstOrDefault();
                if ( recipient != null )
                {
                    // Add any additional merge fields created through a report
                    foreach ( var mergeField in recipient.AdditionalMergeValues )
                    {
                        if ( !mergeValues.ContainsKey( mergeField.Key ) )
                        {
                            mergeValues.Add( mergeField.Key, mergeField.Value );
                        }
                    }
                }
            }

            string message = communication.GetMediumDataValue( "NoReply_Message" );
            return message.ResolveMergeFields( mergeValues );
        }
コード例 #25
0
ファイル: MemberService.cs プロジェクト: jkilgore/Rock-ChMS
        public void AddMember( Rock.Models.Groups.Member Member )
        {
            if ( Member.Guid == Guid.Empty )
                Member.Guid = Guid.NewGuid();

            _repository.Add( Member );
        }
コード例 #26
0
        public void AddSiteDomain( Rock.Models.Cms.SiteDomain SiteDomain )
        {
            if ( SiteDomain.Guid == Guid.Empty )
                SiteDomain.Guid = Guid.NewGuid();

            _repository.Add( SiteDomain );
        }
コード例 #27
0
ファイル: ServiceObjects.cs プロジェクト: ChuckWare/Rock-ChMS
        /// <summary>
        /// Geocodes the specified address.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <param name="result">The ServiceObjects result.</param>
        /// <returns>
        /// True/False value of whether the address was standardized succesfully
        /// </returns>
        public override bool Geocode( Rock.CRM.Address address, out string result )
        {
            if ( address != null )
            {
                string licenseKey = AttributeValue("LicenseKey");

                var client = new DOTSGeoCoderSoapClient();
                Location_V3 location = client.GetBestMatch_V3(
                    string.Format("{0} {1}",
                        address.Street1,
                        address.Street2),
                    address.City,
                    address.State,
                    address.Zip,
                    licenseKey );

                result = location.Level;

                if ( location.Level == "S" || location.Level == "P" )
                {
                    address.Latitude = double.Parse( location.Latitude );
                    address.Longitude = double.Parse( location.Longitude );

                    return true;
                }
            }
            else
                result = "Null Address";

            return false;
        }
コード例 #28
0
        public override bool Execute(RockContext rockContext, Rock.Model.WorkflowAction action, Object entity, out List<string> errorMessages)
        {
            var rand = new Random();
            var checkInState = GetCheckInState(entity, out errorMessages);
            if (checkInState != null)
            {
                var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault();
                if (family != null)
                {
                    var remove = GetAttributeValue(action, "Remove").AsBoolean();

                    foreach (var person in family.People.Where(p => p.Selected))
                    {
                        foreach (var groupType in person.GroupTypes.Where(gt => gt.Selected))
                        {
                            foreach (var group in groupType.Groups.Where(g => g.Selected))
                            {

                                int numValidLocations = group.Locations.Take(2).Count();
                                if (numValidLocations > 0)
                                {
                                    CheckInLocation bestLocation = null;
                                    if (numValidLocations == 1)
                                    {
                                        bestLocation = group.Locations.FirstOrDefault();
                                    }
                                    else
                                    {
                                        bestLocation = group.Locations.Where(l => !l.ExcludedByFilter && l.Schedules.Any(s => s.Schedule.IsCheckInActive)).OrderBy(l => KioskLocationAttendance.Read(l.Location.Id).CurrentCount).FirstOrDefault();
                                    }

                                    if (bestLocation != null)
                                    {
                                        foreach (var location in group.Locations.ToList())
                                        {
                                            if (location != bestLocation)
                                            {
                                                if (remove)
                                                {
                                                    group.Locations.Remove(location);
                                                }
                                                else
                                                {
                                                    location.ExcludedByFilter = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return true;
            }

            return false;
        }
コード例 #29
0
 public OrePatch(int xPos, int yPos, int _density, Rock.RockType rockT)
 {
     leadPositionX = xPos;
     leadPositionY = yPos;
     density = _density;
     totalInPatch = _density;
     rockType = rockT;
 }
コード例 #30
0
 public ImpactLocation( Rock.Model.Location location )
 {
     Street1 = location.Street1;
     Street2 = location.Street2;
     City = location.City;
     State = location.State;
     Zip = location.Zip;
 }
コード例 #31
0
 public Roshambo(Name nm, Rock rk, Paper pr, Scissors sc) : this(new Id("0"), nm, rk, pr, sc, true)
 {
 }
コード例 #32
0
    static void Main()
    {
        Console.BufferHeight = Console.WindowHeight = 25; //defines the height of the console
        Console.BufferWidth  = Console.WindowWidth = 70;  //defines the width of the console
        int    score          = 0;
        double speed          = 100;
        double acceleration   = 0.5;
        int    playFieldWidth = 31; //the width of out playing field
        int    livesCount     = 3;

        Rock dwarf = new Rock(); // this is our dwarf with its values

        dwarf.x     = 16;
        dwarf.y     = Console.WindowHeight - 1;
        dwarf.c     = '0';
        dwarf.color = ConsoleColor.Cyan;

        Random      randomGenerator = new Random();      //this is a random generator that generates random objects on random place
        List <Rock> objects         = new List <Rock>(); // this is our list with obsticles in which can be added or removed obsticles
        int         chance          = randomGenerator.Next(0, 100);

        while (true)
        {
            speed += acceleration;
            if (speed > 320)
            {
                speed = 320;
            }
            bool   hitted       = false;
            char[] fallingRocks = new char[12] {
                '^', '@', '*', '&', '+', '%', '$', '#', '!', '.', ';', '-'
            };
            int          randomRocks = randomGenerator.Next(0, 12);
            char         rock        = fallingRocks[randomRocks];
            ConsoleColor color       = new ConsoleColor();
            switch (randomGenerator.Next(0, 5))
            {
            case 1:
                color = ConsoleColor.Gray;
                break;

            case 2:
                color = ConsoleColor.Magenta;
                break;

            case 3:
                color = ConsoleColor.Yellow;
                break;

            case 4:
                color = ConsoleColor.Red;
                break;

            default:
                break;
            }
            Rock rockObject = new Rock();
            rockObject.c     = rock;
            rockObject.color = color;
            rockObject.x     = randomGenerator.Next(0, playFieldWidth);
            rockObject.y     = 0;
            objects.Add(rockObject);


            while (Console.KeyAvailable) //this while circle moves our dwarf to the left or to the right, depending which arrow we pressed
            {
                ConsoleKeyInfo pressedKey = Console.ReadKey(true);
                if (pressedKey.Key == ConsoleKey.LeftArrow)
                {
                    if (dwarf.x - 1 >= 0)
                    {
                        dwarf.x--;
                    }
                }
                else if (pressedKey.Key == ConsoleKey.RightArrow)
                {
                    if (dwarf.x + 1 < playFieldWidth)
                    {
                        dwarf.x++;
                    }
                }
            }
            List <Rock> newList = new List <Rock>();
            for (int i = 0; i < objects.Count; i++) // this cicle moves our obsticles
            {
                Rock oldRocks  = objects[i];
                Rock newObject = new Rock();
                newObject.x     = oldRocks.x;
                newObject.y     = oldRocks.y + 1;
                newObject.c     = oldRocks.c;
                newObject.color = oldRocks.color;
                if (newObject.y == dwarf.y && newObject.x == dwarf.x) // this checks if we are hit by something
                {
                    livesCount--;
                    hitted = true;
                    speed += 50;
                    if (speed > 320)
                    {
                        speed = 320;
                    }
                    if (livesCount <= 0)
                    {
                        PrintStringOnPosition(35, 10, "GAME OVER!", ConsoleColor.Red);
                        PrintStringOnPosition(35, 12, "Press [enter] to exit", ConsoleColor.Red);
                        Console.ReadLine();
                        Environment.Exit(0);
                    }
                }
                if (newObject.y < Console.WindowHeight)
                {
                    newList.Add(newObject);
                }
            }
            objects = newList;
            Console.Clear(); //this clears the whole console
            if (hitted)      // if you are hit it clears the objects in order to be easier
            {
                objects.Clear();
                PrintOnPosition(dwarf.x, dwarf.y, 'X', ConsoleColor.Red);
            }
            else
            {
                PrintOnPosition(dwarf.x, dwarf.y, dwarf.c, dwarf.color);
            }
            foreach (Rock something in objects)
            {
                PrintOnPosition(something.x, something.y, something.c, something.color);
            }
            foreach (Rock something1 in objects)
            {
                PrintOnPosition(something1.x, something1.y, something1.c, something1.color);
            }
            score++;
            PrintStringOnPosition(35, 4, "Lives: " + livesCount, ConsoleColor.White);
            PrintStringOnPosition(35, 5, "Score: " + score, ConsoleColor.White);
            PrintStringOnPosition(35, 6, "Speed: " + speed, ConsoleColor.White);
            Thread.Sleep((int)(400 - speed)); //makes the game to run by its self without touching anything.
        }
    }
コード例 #33
0
ファイル: Rock.cs プロジェクト: leziz/RockPaperScissorsGame
 public Outcome GetOutcome(Rock rock)
 {
     return(Outcome.TIE);
 }
コード例 #34
0
ファイル: SGolem.cs プロジェクト: BenSchu438/CIS497-SPRING
 public SGolem()
 {
     child = new NoBabies();
     noise = new Rock();
     name  = "small golem";
 }
コード例 #35
0
ファイル: FallingRocks.cs プロジェクト: HMNikolova/Exercises
    static void Main()
    {
        Rock[] rocks = new Rock[31];
        int    count = 0;

        Console.CursorVisible = false;
        Pad pad   = new Pad(30);
        int score = 0;
        int speed = 1;

        for (int i = 0; i < 30; i++)
        {
            for (int j = 0; j < 62; j++)
            {
                if (j == 0 || j == 61)
                {
                    Console.Write(" |");
                }
                else
                {
                    Console.Write(" ");
                }
            }
            Console.WriteLine();
        }
        Console.SetCursorPosition(65, 5);
        Console.WriteLine("SCORE: 0");

        while (true)
        {
            Console.SetCursorPosition(pad.X, 29);
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("(0)");

            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo pressedKey = Console.ReadKey();
                if (pressedKey.Key == ConsoleKey.RightArrow)
                {
                    if (pad.X > 2 && pad.X < 60)
                    {
                        Console.SetCursorPosition(pad.X, 29);
                        pad.X++;
                        Console.Write(" (0)");
                    }
                }
                if (pressedKey.Key == ConsoleKey.LeftArrow)
                {
                    if (pad.X > 2 && pad.X < 60)
                    {
                        Console.SetCursorPosition(pad.X - 1, 29);
                        pad.X--;
                        Console.Write("(0) ");
                    }
                }
            }

            Rock rockTest = new Rock(RandomGen(2, 63), 0, RandomChar(), RandomColor());
            rocks[count] = rockTest;
            for (int i = 0; i <= 30; i++)
            {
                if (rocks[i].Y <= 30)
                {
                    MoveRock(rocks[i]);
                    if (rocks[i].X >= pad.X && rocks[i].X < pad.X + 3 && rocks[i].Y == 29)
                    {
                        Console.SetCursorPosition(27, 14);
                        Console.WriteLine(new string('*', 13));
                        Console.SetCursorPosition(27, 15);
                        Console.WriteLine("* GAME OVER *");
                        Console.SetCursorPosition(27, 16);
                        Console.WriteLine(new string('*', 13));
                        Console.SetCursorPosition(27, 17);
                        return;
                    }
                    rocks[i].Y++;
                    if (rocks[i].Y == 31)
                    {
                        score++;
                    }
                }
            }

            count++;
            if (count == 31)
            {
                count = 0;
            }

            Console.SetCursorPosition(72, 5);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write(score);
            if (score > 99 && score % 100 == 0)
            {
                speed += 5;
            }
            Thread.Sleep(200 - speed);
        }
    }
コード例 #36
0
    static void Main()
    {
        int playfieldWidth = 30;
        int livesCount     = 5;
        int score          = 0;
        int hardGame       = 150;

        Console.BufferHeight = Console.WindowHeight = 30; //size of field
        Console.BufferWidth  = Console.WindowWidth = 60;  //size of field
        Console.Title        = "Falling Rocks";

        Rock user = new Rock();// dwarf

        user.x       = 15;
        user.y       = Console.WindowHeight - 1;
        user.strDraw = "(0)";
        user.color   = ConsoleColor.White;

        Random      randomGenerator = new Random();      // random generation
        List <Rock> rocks           = new List <Rock>(); //list of rocks


        while (true)
        {
            bool hitted = false;
            {
                Rock newRock = new Rock();// rocks settings
                newRock.x = randomGenerator.Next(0, playfieldWidth);
                int y = randomGenerator.Next(rocksChar.Length);
                newRock.color = rockColors[randomGenerator.Next(1, 16)];
                newRock.y     = 0;
                newRock.r     = rocksChar[y];
                rocks.Add(newRock);
            }

            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo pressedKey = Console.ReadKey(true);
                while (Console.KeyAvailable)
                {
                    Console.ReadKey(true);
                }

                if (pressedKey.Key == ConsoleKey.LeftArrow)
                {
                    if (user.x - 1 >= 0)
                    {
                        user.x = user.x - 1; //move left
                    }
                }

                else if (pressedKey.Key == ConsoleKey.RightArrow)
                {
                    if (user.x + 1 < playfieldWidth)
                    {
                        user.x = user.x + 1; //move right
                    }
                }
            }
            List <Rock> newList = new List <Rock>();

            for (int i = 0; i < rocks.Count; i++)
            {
                Rock oldRock = rocks[i];
                Rock newRock = new Rock();
                newRock.x     = oldRock.x;
                newRock.y     = oldRock.y + 1;
                newRock.r     = oldRock.r;
                newRock.color = oldRock.color;
                score++;
                if (newRock.y == user.y && newRock.x == user.x || newRock.y == user.y && newRock.x == user.x + 1 || newRock.y == user.y && newRock.x == user.x + 2)
                {
                    livesCount--;
                    hitted = true;
                    if (livesCount <= 0)
                    {
                        PrintStringOnPosition(40, 10, "GAME OVER!!!", ConsoleColor.Red);
                        PrintStringOnPosition(35, 12, "Press [enter] to exit...", ConsoleColor.Red);
                        Console.ReadLine();
                        return;
                    }
                }
                if (newRock.y < Console.WindowHeight)
                {
                    newList.Add(newRock);
                }
            }
            rocks = newList;

            Console.Clear();

            PrintOnDwarfPosition(user.x, user.y, user.strDraw, user.color); //print dwarf
            foreach (Rock rock in rocks)
            {
                PrintOnPosition(rock.x, rock.y, rock.r, rock.color);     //print rocks
            }
            if (hitted)
            {
                PrintOnDwarfPosition(user.x, user.y, "(X)", ConsoleColor.Red);
            }

            PrintStringOnPosition(40, 10, "Lives: " + livesCount, ConsoleColor.White);
            PrintStringOnPosition(40, 11, "Score: " + score, ConsoleColor.White);

            Thread.Sleep(hardGame);     //slow the game;
        }
    }
コード例 #37
0
    static void Main()
    {
        SetBufferSize();

        int playfieldWidth = 2 * Console.WindowWidth / 3;

        // creating the dwarf
        Dwarf dwarf = new Dwarf();

        dwarf.positionX = playfieldWidth / 2;
        dwarf.positionY = Console.WindowHeight - 1;
        dwarf.color     = ConsoleColor.Yellow;
        dwarf.symbols   = "(0)";

        Random rand = new Random();

        List <Rock> rocks    = new List <Rock>();
        bool        isHitted = false;

        int    livesCount = 2;
        int    counterWhenToCreateRock = 0;
        int    userScore    = 0;
        double acceleration = 0.0;

        int intervalForCreatingRocks = 0;

        while (true)
        {
            dwarf = MoveDwarf(playfieldWidth, dwarf);  // moving dwarf when left or right arrow is pressed

            // depending on the userScore, increase acceleration
            //acceleration = increaseAcceleration(userScore);

            intervalForCreatingRocks = decreaseIntervalForCreatingRocks(userScore); // in some conditions decrease the interval for creating rocks

            // in every intervalForCreatingRocks time we will create one rock and add it to the list of rocks
            if (counterWhenToCreateRock % intervalForCreatingRocks == 0)
            {
                counterWhenToCreateRock = 0;
                Rock createdRock = CreateRock(playfieldWidth, rand);
                rocks.Add(createdRock);
            }

            List <Rock> movedRocks = MoveRocks(rocks); // move rocks one position down

            for (int i = 0; i < movedRocks.Count; i++) // loop for every rock in movedRocks
            {
                Rock currentRock = new Rock();
                currentRock = movedRocks[i];

                // check if some rock hit the dwarf
                if (currentRock.y == dwarf.positionY && (dwarf.positionX <= currentRock.x + currentRock.symbols.Length - 1) && (dwarf.positionX + dwarf.symbols.Length - 1 >= currentRock.x))
                {
                    //if the dwarf is hit, and there is any lives left, decrease lives with 1 and set isHitted to true
                    if (livesCount - 1 >= 0)
                    {
                        livesCount--;
                        isHitted = true;
                    }
                }

                //check is there is no more lives, and if there isn't print some information ot the console
                if (livesCount <= 0)
                {
                    Console.Clear();
                    Draw(Console.WindowWidth / 2 - 5, Console.WindowHeight / 2 + 2, ConsoleColor.DarkRed, "GAME OVER");
                    Draw(Console.WindowWidth / 2 - 6, Console.WindowHeight / 2 - 2, ConsoleColor.DarkRed, "Your score: " + userScore);
                    Draw(Console.WindowWidth / 2 - 10, Console.WindowHeight / 2 - 4, ConsoleColor.DarkRed, "Press any key to exit");

                    Console.ReadLine();
                    return;
                }

                //check if rock is on the board of the console, and if it is increase userScore with the lenght of the rock
                if (currentRock.y == Console.WindowHeight - 1 && !isHitted)
                {
                    userScore += currentRock.symbols.Length;
                }
            }

            rocks = movedRocks;

            // clear the console from previous output and after that print the moved rocks, the dwarf and some information on the right
            Console.Clear();

            //check if the dwarf is hit
            if (isHitted)
            {
                //if dwarf was hitted clear rocks so that we begin our game from the beggining and draw (X) with DarkRed to see that we were hitted
                rocks.Clear();
                Draw(dwarf.positionX, dwarf.positionY, ConsoleColor.DarkRed, "(X)");
            }
            else
            {
                //if it was not hitted than draw the dwarf
                Draw(dwarf.positionX, dwarf.positionY, dwarf.color, dwarf.symbols);
            }

            // draw every rock from the current list of rocks
            foreach (Rock rock in rocks)
            {
                Draw(rock.x, rock.y, rock.color, rock.symbols);
            }

            //print some information about the game
            Draw(playfieldWidth + 2, Console.WindowHeight / 2 - 6, ConsoleColor.Red, "Lives left: " + livesCount);
            Draw(playfieldWidth + 2, Console.WindowHeight / 2 - 2, ConsoleColor.Red, "Score: " + userScore);
            Draw(playfieldWidth + 2, Console.WindowHeight / 2 + 2, ConsoleColor.Red, "Time for rock falling: " + intervalForCreatingRocks);


            //if you want to play the game with acceleration, not with constant speed of falling

            /*
             * if ((int) userScore * acceleration < 350)
             * {
             *  Thread.Sleep(500 - (int) (userScore * acceleration));
             * }
             * else
             * {
             *  Thread.Sleep(150);
             * }
             */

            Thread.Sleep(150);

            counterWhenToCreateRock++;
            isHitted = false;
        }
    }
コード例 #38
0
 public void Rocks()
 {
     var chunk = Rock.Make<IThingy>();
     chunk.DoNothing();
 }
コード例 #39
0
ファイル: Program.cs プロジェクト: Dayghini/Homework
    static void Main(string[] args)
    {
        double speed         = 100.0;
        int    playFieldWith = 20;
        int    livesCount    = 5;


        Console.BufferHeight = Console.WindowHeight = 30;
        Console.BufferWidth  = Console.WindowWidth = 60;


        Rock userRock = new Rock();

        userRock.x      = 2;
        userRock.y      = Console.WindowHeight - 1;
        userRock.symbol = '@';
        userRock.color  = ConsoleColor.Blue;

        Random      randomGenerator = new Random();
        List <Rock> rocks           = new List <Rock>();

        while (true)
        {
            speed++;
            if (speed > 400)
            {
                speed = 400;
            }

            bool hitted = false;
            {
                Rock newRock = new Rock();
                newRock.color  = ConsoleColor.Green;
                newRock.x      = randomGenerator.Next(0, playFieldWith);
                newRock.y      = 0;
                newRock.symbol = '#';
                rocks.Add(newRock);
            }


            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo presedKey = Console.ReadKey(true);


                while (Console.KeyAvailable)
                {
                    Console.ReadKey(true);
                }

                if (presedKey.Key == ConsoleKey.LeftArrow)
                {
                    if (userRock.x - 1 >= 0)
                    {
                        userRock.x = userRock.x - 1;
                    }
                }
                else if (presedKey.Key == ConsoleKey.RightArrow)
                {
                    if (userRock.x + 1 < playFieldWith)
                    {
                        userRock.x = userRock.x + 1;
                    }
                }
            }

            List <Rock> newList = new List <Rock>();

            for (int i = 0; i < rocks.Count; i++)
            {
                Rock oldRock = rocks[i];
                Rock newRock = new Rock();
                newRock.x      = oldRock.x;
                newRock.y      = oldRock.y + 1;
                newRock.symbol = oldRock.symbol;
                newRock.color  = oldRock.color;

                if (newRock.y == userRock.y && newRock.x == userRock.x)
                {
                    livesCount--;
                    hitted = true;
                    speed += 50;

                    if (speed > 400)
                    {
                        speed = 400;
                    }

                    if (livesCount <= 0)
                    {
                        PrintStringOnPosition(8, 7, "Game Over!!!", ConsoleColor.Red);
                        PrintStringOnPosition(8, 10, "Press [Press Enter] to exit ...", ConsoleColor.Red);
                        Console.ReadLine();
                        Environment.Exit(0);
                    }
                }

                if (newRock.y < Console.WindowHeight)
                {
                    newList.Add(newRock);
                }
            }

            rocks = newList;


            Console.Clear();

            foreach (Rock rock in rocks)
            {
                PrintOnPosition(rock.x, rock.y, rock.symbol, rock.color);
            }

            if (hitted)
            {
                PrintOnPosition(userRock.x, userRock.y, 'X', ConsoleColor.Red);
                Console.Beep();
            }
            else
            {
                PrintOnPosition(userRock.x, userRock.y, userRock.symbol, userRock.color);
            }


            PrintStringOnPosition(30, 4, "Lives: " + livesCount, ConsoleColor.White);
            PrintStringOnPosition(30, 5, "Speed: " + speed, ConsoleColor.White);


            Thread.Sleep((int)(500 - speed));
        }
    }
コード例 #40
0
    private void HandleClicks()
    {
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if ((Input.GetMouseButtonUp(0) && matchTimer.matchStarted))
            {
                Ray screenToWorld = viewportCamera.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(screenToWorld, out RaycastHit raycastHit))
                {
                    clickerAudio.PlayInspect();
                    Collider other = raycastHit.collider;
                    switch (other.tag)
                    {
                    case "Building":
                        ClearSelections();
                        selectedBuilding = other.GetComponentInParent <Building>();
                        selectedBuilding.FocusOnBuilding();
                        upgradeMenuObj.SetActive(true);
                        //upgradeMenu.PopulateList(selectedBuilding.upgrades);
                        upgradeMenu.SetSelectedBuilding(selectedBuilding);
                        break;

                    case "Plot":
                        ClearSelections();
                        Building.UnfocusAllBuildings();
                        selectedPlot = other.GetComponentInParent <Plot>();
                        selectedPlot.FocusOnPlot();
                        if (selectedPlot.size == (Plot.PlotSize) 0)
                        {
                            buildMenuObj[2].SetActive(true);
                        }
                        else if (selectedPlot.size == (Plot.PlotSize) 1)
                        {
                            buildMenuObj[0].SetActive(true);
                        }
                        else if (selectedPlot.size == (Plot.PlotSize) 2)
                        {
                            buildMenuObj[1].SetActive(true);
                        }
                        break;

                    case "Forest":
                        ClearSelections();
                        selectedForest = other.GetComponent <Forest>();
                        buyTileMenu.SetSelectedTile(selectedForest);
                        buyMenuObj.SetActive(true);
                        if (!selectedForest.finished)
                        {
                            buyTileMenu.buildButtons[0].SetActive(true);
                        }
                        if (selectedForest.building)
                        {
                            buyTileMenu.buildButtons[0].SetActive(false);
                            buyTileMenu.buildButtons[1].SetActive(true);
                            buyTileMenu.buildButtons[1].GetComponent <Button>().interactable = false;
                        }
                        if (selectedForest.finished)
                        {
                            buyTileMenu.buildButtons[1].SetActive(true);
                            buyTileMenu.buildButtons[1].GetComponent <Button>().interactable = true;
                        }
                        break;

                    case "Rock":
                        ClearSelections();
                        selectedRock = other.GetComponent <Rock>();
                        buyTileMenu.SetSelectedTile(selectedRock);
                        buyMenuObj.SetActive(true);

                        if (!selectedRock.finished)
                        {
                            buyTileMenu.buildButtons[3].SetActive(true);
                        }
                        if (selectedRock.building)
                        {
                            buyTileMenu.buildButtons[3].SetActive(false);
                            buyTileMenu.buildButtons[4].SetActive(true);
                            buyTileMenu.buildButtons[4].GetComponent <Button>().interactable = false;
                        }
                        if (selectedRock.finished)
                        {
                            buyTileMenu.buildButtons[4].SetActive(true);
                            buyTileMenu.buildButtons[4].GetComponent <Button>().interactable = true;
                        }
                        break;

                    case "WorldTile":
                        ClearSelections();
                        selectedTile = other.GetComponent <WorldTile>();
                        selectedTile.GetComponent <Animator>().SetBool("Focused", true);
                        buyTileMenu.SetSelectedTile(selectedTile);
                        if (!selectedTile.purchased)
                        {
                            buyMenuObj.SetActive(true);
                            buyTileMenu.buildButtons[2].SetActive(true);
                        }
                        break;

                    case "SkullIsland":
                        bombCounter++;
                        Debug.Log(bombCounter);
                        nukeSource = nukeAudio.GetComponent <AudioSource>();
                        nukeSource.PlayOneShot(nukeAudio.dontDoIt[bombCounter - 1]);
                        if (bombCounter == 5)
                        {
                            nuke = other.GetComponent <NukeTime>();
                            nuke.nukeTime();
                        }
                        break;

                    default:
                        ClearSelections();
                        break;
                    }
                }
            }
        }
    }
コード例 #41
0
 private void RockPress(Rock pedra)
 {
     //Debug.Log("Pedra action");
     pedra.ActivateSwitch();
 }
コード例 #42
0
    static void Main(string[] args)
    {
        string[]  inputs;
        ArrayList rocks = new ArrayList();

        inputs = Console.ReadLine().Split(' ');
        W      = int.Parse(inputs[0]);
        H      = int.Parse(inputs[1]);
        rooms  = new Room[H, W];
        for (int i = 0; i < H; i++)
        {
            string[] LINE = Console.ReadLine().Split(' ');
            for (int j = 0; j < W; j++)
            {
                rooms[i, j] = new Room(i, j, int.Parse(LINE[j]));
            }
        }
        int EX = int.Parse(Console.ReadLine());

        rooms[H - 1, EX].EXIT = true;
        bool flag  = false;
        int  count = 0;
        int  wait  = 0;

        while (true)
        {
            inputs = Console.ReadLine().Split(' ');
            int    XI   = int.Parse(inputs[0]);
            int    YI   = int.Parse(inputs[1]);
            string POSI = inputs[2];
            if (!flag)
            {
                search(YI, XI, POSI);
                count = trace.Count;
                flag  = true;
            }

            int R = int.Parse(Console.ReadLine());
            if (R > 0)
            {
                rocks.Clear();
                for (int i = 0; i < R; i++)
                {
                    inputs = Console.ReadLine().Split(' ');
                    Rock r2 = new Rock(int.Parse(inputs[1]), int.Parse(inputs[0]), inputs[2]);
                    rocks.Add(r2);
                }
            }

            if (trace.Count > 0)
            {
                Room test = trace.Peek() as Room;
                test.BASETYPE = rooms[test.XI, test.YI].BASETYPE;
                if (!test.needRotate())
                {
                    trace.Pop();
                    if (trace.Count > 0)
                    {
                        test          = trace.Peek() as Room;
                        test.BASETYPE = rooms[test.XI, test.YI].BASETYPE;
                    }
                }
                if (!test.needRotate())
                {
                    int index = 0;
                    if (R > 0)
                    {
                        bool flag_rock = false;
                        while (kill_rocks(YI, XI, POSI, rocks[index++] as Rock) == 0)
                        {
                            if (index == rocks.Count)
                            {
                                flag_rock = true;
                                break;
                            }
                        }
                        if (!flag_rock)
                        {
                            continue;
                        }
                    }

                    while (test.rotate() == 0)
                    {
                        wait++;
                        if (trace.Count == 0)
                        {
                            break;
                        }
                        test          = trace.Peek() as Room;
                        test.BASETYPE = rooms[test.XI, test.YI].BASETYPE;
                        if (!test.needRotate())
                        {
                            trace.Pop();
                        }
                    }
                }
                else
                {
                    test.rotate();
                }
            }
            if (trace.Count == 0)
            {
                for (int i = 0; i < wait; i++)
                {
                    Console.WriteLine("WAIT");
                }
            }
        }
    }
コード例 #43
0
        static void Main(string[] args)
        {
            //set the gamefield parameters
            Console.WindowHeight = 25;
            Console.WindowWidth  = 80;
            int      maxCurrentRock = 10;
            DateTime startGameTime  = DateTime.Now;
            int      oldscore       = 0;
            int      score          = 0;
            int      gamespeed      = 200;

            //put first ten rocks on the field
            Rock[] newRock = new Rock[100];
            for (int i = 0; i < maxCurrentRock; i++)
            {
                newRock[i] = InitializeNewRock();
            }

            //put the dwarf on the field
            int dwarfXPosition = (Console.WindowWidth / 2) - 2;
            int dwarfYPosition = Console.WindowHeight - 1;

            WriteDwarf(dwarfXPosition, dwarfYPosition);

            while (true)
            {
                //sets game speed
                Thread.Sleep(gamespeed);

                //shows current score
                Console.SetCursorPosition(0, 0);
                Console.Write("Score: {0:F0}", score);

                //check if dwarf is moving
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo userInput = Console.ReadKey();
                    if (userInput.Key == ConsoleKey.RightArrow)
                    {
                        if (dwarfXPosition + 6 < Console.WindowWidth)
                        {
                            dwarfXPosition++;
                            WriteDwarf(dwarfXPosition, dwarfYPosition);
                        }
                    }
                    if (userInput.Key == ConsoleKey.LeftArrow)
                    {
                        if (dwarfXPosition > 0)
                        {
                            dwarfXPosition--;
                            WriteDwarf(dwarfXPosition, dwarfYPosition);
                        }
                    }
                }

                //checks for collision
                for (int i = 0; i < maxCurrentRock; i++)
                {
                    if (newRock[i].Y == Console.WindowHeight - 1)
                    {
                        if ((newRock[i].X > dwarfXPosition) && (newRock[i].X < (dwarfXPosition + 4)))
                        {
                            WriteDeadDwarf(dwarfXPosition, dwarfYPosition);
                            Console.SetCursorPosition(0, 0);
                            Console.WriteLine("\aGame over");
                            Thread.Sleep(250);
                            Console.WriteLine("\aYour score is {0}", score);
                            Console.ReadKey();
                            return;
                        }
                    }
                }

                //start moving rocks
                for (int i = 0; i < maxCurrentRock; i++)
                {
                    newRock[i] = MoveRock(newRock[i]);
                }

                //calculates score and increas dificulty
                score = (int)(DateTime.Now - startGameTime).TotalSeconds;
                if ((score - oldscore) > 10)
                {
                    oldscore = score;
                    maxCurrentRock++;
                    newRock[maxCurrentRock] = InitializeNewRock();
                }
                if ((score - oldscore) > 25)
                {
                    gamespeed -= 20;
                }
            }
        }
コード例 #44
0
        public static void MakeWithHandler()
        {
            var argumentA         = 0;
            var argumentB         = 0;
            var argumentC         = 0;
            var argumentD         = 0;
            var argumentE         = 0;
            var argumentF         = 0;
            var argumentG         = 0;
            var argumentH         = 0;
            var argumentI         = 0;
            var argumentJ         = 0;
            var argumentK         = 0;
            var argumentL         = 0;
            var stringReturnValue = "a";
            var intReturnValue    = 1;

            var rock = Rock.Create <IHandleFunc12ArgumentTests>();

            rock.Handle <int, int, int, int, int, int, int, int, int, int, int, int, string>(_ => _.ReferenceTarget(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
                                                                                             (a, b, c, d, e, f, g, h, i, j, k, l) => { argumentA = a; argumentB = b; argumentC = c; argumentD = d; argumentE = e; argumentF = f; argumentG = g; argumentH = h; argumentI = i; argumentJ = j; argumentK = k; argumentL = l; return(stringReturnValue); });
            rock.Handle <int, int, int, int, int, int, int, int, int, int, int, int, int>(_ => _.ValueTarget(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120),
                                                                                          (a, b, c, d, e, f, g, h, i, j, k, l) => { argumentA = a; argumentB = b; argumentC = c; argumentD = d; argumentE = e; argumentF = f; argumentG = g; argumentH = h; argumentI = i; argumentJ = j; argumentK = k; argumentL = l; return(intReturnValue); });

            var chunk = rock.Make();

            Assert.That(chunk.ReferenceTarget(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
                        Is.EqualTo(stringReturnValue), nameof(chunk.ReferenceTarget));
            Assert.That(argumentA, Is.EqualTo(1), nameof(argumentA));
            Assert.That(argumentB, Is.EqualTo(2), nameof(argumentB));
            Assert.That(argumentC, Is.EqualTo(3), nameof(argumentC));
            Assert.That(argumentD, Is.EqualTo(4), nameof(argumentD));
            Assert.That(argumentE, Is.EqualTo(5), nameof(argumentE));
            Assert.That(argumentF, Is.EqualTo(6), nameof(argumentF));
            Assert.That(argumentG, Is.EqualTo(7), nameof(argumentG));
            Assert.That(argumentH, Is.EqualTo(8), nameof(argumentH));
            Assert.That(argumentI, Is.EqualTo(9), nameof(argumentI));
            Assert.That(argumentJ, Is.EqualTo(10), nameof(argumentJ));
            Assert.That(argumentK, Is.EqualTo(11), nameof(argumentK));
            Assert.That(argumentL, Is.EqualTo(12), nameof(argumentL));
            argumentA = 0;
            argumentB = 0;
            argumentC = 0;
            argumentD = 0;
            argumentE = 0;
            argumentF = 0;
            argumentG = 0;
            argumentH = 0;
            argumentI = 0;
            argumentJ = 0;
            argumentK = 0;
            argumentL = 0;
            Assert.That(chunk.ValueTarget(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120),
                        Is.EqualTo(intReturnValue), nameof(chunk.ValueTarget));
            Assert.That(argumentA, Is.EqualTo(10), nameof(argumentA));
            Assert.That(argumentB, Is.EqualTo(20), nameof(argumentB));
            Assert.That(argumentC, Is.EqualTo(30), nameof(argumentC));
            Assert.That(argumentD, Is.EqualTo(40), nameof(argumentD));
            Assert.That(argumentE, Is.EqualTo(50), nameof(argumentE));
            Assert.That(argumentF, Is.EqualTo(60), nameof(argumentF));
            Assert.That(argumentG, Is.EqualTo(70), nameof(argumentG));
            Assert.That(argumentH, Is.EqualTo(80), nameof(argumentH));
            Assert.That(argumentI, Is.EqualTo(90), nameof(argumentI));
            Assert.That(argumentJ, Is.EqualTo(100), nameof(argumentJ));
            Assert.That(argumentK, Is.EqualTo(110), nameof(argumentK));
            Assert.That(argumentL, Is.EqualTo(120), nameof(argumentL));

            rock.Verify();
        }
コード例 #45
0
        public static void MakeWithHandlerAndExpectedCallCount()
        {
            var argumentA = 0;
            var argumentB = 0;
            var argumentC = 0;
            var argumentD = 0;
            var argumentE = 0;
            var argumentF = 0;
            var argumentG = 0;
            var argumentH = 0;
            var argumentI = 0;
            var argumentJ = 0;
            var argumentK = 0;
            var argumentL = 0;
            var argumentM = 0;

            var rock = Rock.Create <IHandleAction13ArgumentTests>();

            rock.Handle <int, int, int, int, int, int, int, int, int, int, int, int, int>(_ => _.Target(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
                                                                                          (a, b, c, d, e, f, g, h, i, j, k, l, m) => { argumentA = a; argumentB = b; argumentC = c; argumentD = d; argumentE = e; argumentF = f; argumentG = g; argumentH = h; argumentI = i; argumentJ = j; argumentK = k; argumentL = l; argumentM = m; }, 2);

            var chunk = rock.Make();

            chunk.Target(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
            Assert.That(argumentA, Is.EqualTo(1), nameof(argumentA));
            Assert.That(argumentB, Is.EqualTo(2), nameof(argumentB));
            Assert.That(argumentC, Is.EqualTo(3), nameof(argumentC));
            Assert.That(argumentD, Is.EqualTo(4), nameof(argumentD));
            Assert.That(argumentE, Is.EqualTo(5), nameof(argumentE));
            Assert.That(argumentF, Is.EqualTo(6), nameof(argumentF));
            Assert.That(argumentG, Is.EqualTo(7), nameof(argumentG));
            Assert.That(argumentH, Is.EqualTo(8), nameof(argumentH));
            Assert.That(argumentI, Is.EqualTo(9), nameof(argumentI));
            Assert.That(argumentJ, Is.EqualTo(10), nameof(argumentJ));
            Assert.That(argumentK, Is.EqualTo(11), nameof(argumentK));
            Assert.That(argumentL, Is.EqualTo(12), nameof(argumentL));
            Assert.That(argumentM, Is.EqualTo(13), nameof(argumentM));
            argumentA = 0;
            argumentB = 0;
            argumentC = 0;
            argumentD = 0;
            argumentE = 0;
            argumentF = 0;
            argumentG = 0;
            argumentH = 0;
            argumentI = 0;
            argumentJ = 0;
            argumentK = 0;
            argumentL = 0;
            argumentM = 0;
            chunk.Target(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
            Assert.That(argumentA, Is.EqualTo(1), nameof(argumentA));
            Assert.That(argumentB, Is.EqualTo(2), nameof(argumentB));
            Assert.That(argumentC, Is.EqualTo(3), nameof(argumentC));
            Assert.That(argumentD, Is.EqualTo(4), nameof(argumentD));
            Assert.That(argumentE, Is.EqualTo(5), nameof(argumentE));
            Assert.That(argumentF, Is.EqualTo(6), nameof(argumentF));
            Assert.That(argumentG, Is.EqualTo(7), nameof(argumentG));
            Assert.That(argumentH, Is.EqualTo(8), nameof(argumentH));
            Assert.That(argumentI, Is.EqualTo(9), nameof(argumentI));
            Assert.That(argumentJ, Is.EqualTo(10), nameof(argumentJ));
            Assert.That(argumentK, Is.EqualTo(11), nameof(argumentK));
            Assert.That(argumentL, Is.EqualTo(12), nameof(argumentL));
            Assert.That(argumentM, Is.EqualTo(13), nameof(argumentM));

            rock.Verify();
        }
コード例 #46
0
 public Roshambo(Name nm, Rock rk, Paper pr, Scissors sc, bool en) : this(new Id("0"), nm, rk, pr, sc, en)
 {
 }
コード例 #47
0
ファイル: FallingRocks.cs プロジェクト: adatanasov/Projects
    static void Main()
    {
        RemoveScrollBars();
        SetInitialPosition();
        Random      randomGenerator = new Random();
        List <Rock> rocks           = new List <Rock>();

        while (true)
        {
            Rock userRock = new Rock();
            userRock.color = ConsoleColor.Red;
            userRock.x     = randomGenerator.Next(0, Console.WindowWidth - 1);
            userRock.y     = 0;
            userRock.l     = randomGenerator.Next(0, 4);
            userRock.c     = '^';
            rocks.Add(userRock);
            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                while (Console.KeyAvailable)
                {
                    Console.ReadKey(true);
                }
                if (keyInfo.Key == ConsoleKey.LeftArrow)
                {
                    MovePlayerLeft();
                }
                if (keyInfo.Key == ConsoleKey.RightArrow)
                {
                    MovePlayerRight();
                }
            }
            List <Rock> newList = new List <Rock>();
            for (int i = 0; i < rocks.Count; i++)
            {
                Rock oldRock = rocks[i];
                Rock newRock = new Rock();
                newRock.x     = oldRock.x;
                newRock.y     = oldRock.y + 1;
                newRock.c     = oldRock.c;
                newRock.l     = randomGenerator.Next(0, 4);
                newRock.color = oldRock.color;
                if (newRock.y == Console.WindowHeight && newRock.x >= playerPositon && newRock.x < (playerPositon + playerLenght))
                {
                    Console.SetCursorPosition(20, 15);
                    Console.WriteLine("You lose!");
                    Console.ReadKey();
                }
                if (newRock.y == Console.WindowHeight)
                {
                    score++;
                }
                if (newRock.y < Console.WindowHeight)
                {
                    newList.Add(newRock);
                }
            }
            rocks = newList;
            Console.Clear();
            DrawPlayerPosition();
            PrintAtPosition(userRock.x, userRock.y, userRock.c, userRock.color);
            foreach (Rock rock in rocks)
            {
                for (int i = 0; i < rock.l; i++)
                {
                    PrintAtPosition(rock.x, rock.y, rock.c, rock.color);
                }
            }
            PrintScore();
            Thread.Sleep(150);
        }
    }
コード例 #48
0
ファイル: RockHK.cs プロジェクト: Garrakx/Monkland
 public static void Sync(Rock self) => AbstractPhysicalObjectHK.GetField(self.abstractPhysicalObject).networkLife = 60;
コード例 #49
0
ファイル: Scissors.cs プロジェクト: fvia/Code-Dojo-38
 public override bool?Beats(Rock other)
 {
     return(false);
 }
コード例 #50
0
ファイル: Arm.cs プロジェクト: mambotuna/DOTS-training
    void Update()
    {
        float time = Time.time + timeOffset;

        // resting position
        Vector3 idleHandTarget = transform.position + new Vector3(Mathf.Sin(time) * .35f, 1f + Mathf.Cos(time * 1.618f) * .5f, 1.5f);

        if (heldRock == null && windupTimer <= 0f)
        {
            if (intendedRock == null && reachTimer == 0f)
            {
                // we're idle - see if we can grab a rock
                Rock nearestRock = RockManager.NearestConveyorRock(transform.position - Vector3.right * .5f);
                if (nearestRock != null)
                {
                    if ((nearestRock.position - transform.position).sqrMagnitude < maxReachLength * maxReachLength)
                    {
                        // found a rock to grab!
                        // mark it as reserved so other hands don't reach for it
                        intendedRock          = nearestRock;
                        intendedRock.reserved = true;
                        lastIntendedRockSize  = intendedRock.size;
                    }
                }
            }
            else if (intendedRock == null)
            {
                // stop reaching if we've lost our target
                reachTimer -= Time.deltaTime / reachDuration;
            }

            if (intendedRock != null)
            {
                // we're reaching for a rock (but we haven't grabbed it yet)
                Vector3 delta = intendedRock.position - transform.position;
                if (delta.sqrMagnitude < maxReachLength * maxReachLength)
                {
                    // figure out where we want to put our wrist
                    // in order to grab the rock
                    Vector3 flatDelta = delta;
                    flatDelta.y = 0f;
                    flatDelta.Normalize();
                    grabHandTarget      = intendedRock.position + Vector3.up * intendedRock.size * .5f - flatDelta * intendedRock.size * .5f;
                    lastIntendedRockPos = intendedRock.position;

                    reachTimer += Time.deltaTime / reachDuration;
                    if (reachTimer >= 1f)
                    {
                        // we've arrived at the rock - pick it up
                        heldRock = intendedRock;
                        RockManager.RemoveFromConveyor(heldRock);
                        heldRock.state = Rock.State.Held;
                        // remember the rock's position in "hand space"
                        // (so we can position the rock while holding it)
                        heldRockOffset = handMatrix.inverse.MultiplyPoint3x4(heldRock.position);
                        intendedRock   = null;

                        // random minimum delay before starting the windup
                        windupTimer = Random.Range(-1f, 0f);
                        throwTimer  = 0f;
                    }
                }
                else
                {
                    // we didn't grab the rock in time - forget it
                    intendedRock.reserved = false;
                    intendedRock          = null;
                }
            }
        }
        if (heldRock != null)
        {
            // stop reaching after we've successfully grabbed a rock
            reachTimer -= Time.deltaTime / reachDuration;

            if (targetCan == null)
            {
                // find a target
                targetCan = TinCanManager.GetNearestCan(transform.position, true, targetXRange);
            }
            if (targetCan != null)
            {
                // found a target - prepare to throw
                targetCan.reserved = true;
                windupTimer       += Time.deltaTime / windupDuration;
            }
        }

        reachTimer = Mathf.Clamp01(reachTimer);

        // smoothed reach timer
        float grabT = reachTimer;

        grabT = 3f * grabT * grabT - 2f * grabT * grabT * grabT;

        // reaching overrides our idle hand position
        handTarget = Vector3.Lerp(idleHandTarget, grabHandTarget, grabT);

        if (targetCan != null)
        {
            // we've got a target, which means we're currently throwing
            if (windupTimer < 1f)
            {
                // still winding up...
                float windupT = Mathf.Clamp01(windupTimer) - Mathf.Clamp01(throwTimer * 2f);
                windupT    = 3f * windupT * windupT - 2f * windupT * windupT * windupT;
                handTarget = Vector3.Lerp(handTarget, windupHandTarget, windupT);
                Vector3 flatTargetDelta = targetCan.position - transform.position;
                flatTargetDelta.y = 0f;
                flatTargetDelta.Normalize();

                // windup position is "behind us," relative to the target position
                windupHandTarget = transform.position - flatTargetDelta * 2f + Vector3.up * (3f - windupT * 2.5f);
            }
            else
            {
                // done winding up - actual throw, plus resetting to idle
                throwTimer += Time.deltaTime / throwDuration;

                // update our aim until we release the rock
                if (heldRock != null)
                {
                    aimVector = AimAtCan(targetCan, lastIntendedRockPos);
                }

                // we start this animation in our windup position,
                // and end it by returning to our default idle pose
                Vector3 restingPos = Vector3.Lerp(windupHandTarget, handTarget, throwTimer);

                // find the hand's target position to perform the throw
                // (somewhere forward and upward from the windup position)
                Vector3 throwHandTarget = windupHandTarget + aimVector.normalized * 2.5f;

                handTarget = Vector3.LerpUnclamped(restingPos, throwHandTarget, throwCurve.Evaluate(throwTimer));

                if (throwTimer > .15f && heldRock != null)
                {
                    // release the rock
                    heldRock.reserved = false;
                    heldRock.state    = Rock.State.Thrown;
                    heldRock.velocity = aimVector;
                    heldRock          = null;
                }

                if (throwTimer >= 1f)
                {
                    // we've completed the animation - return to idle
                    windupTimer = 0f;
                    throwTimer  = 0f;
                    TinCanManager.UnreserveCanAfterDelay(targetCan, 3f);
                    targetCan = null;
                }
            }
        }

        // solve the arm IK chain first
        FABRIK.Solve(armChain, armBoneLength, transform.position, handTarget, handUp * armBendStrength);

        // figure out our current "hand vectors" from our arm orientation
        handForward = (armChain.Last(0) - armChain.Last(1)).normalized;
        handUp      = Vector3.Cross(handForward, transform.right).normalized;
        handRight   = Vector3.Cross(handUp, handForward);

        // create handspace-to-worldspace matrix
        handMatrix = Matrix4x4.TRS(armChain.Last(), Quaternion.LookRotation(handForward, handUp), Vector3.one);

        // how much are our fingers gripping?
        // (during a reach, this is based on the reach timer)
        float fingerGrabT = grabT;

        if (heldRock != null)
        {
            // move our held rock to match our new hand position
            heldRock.position   = handMatrix.MultiplyPoint3x4(heldRockOffset);
            lastIntendedRockPos = heldRock.position;

            // if we're holding a rock, we're always gripping
            fingerGrabT = 1f;
        }

        // create rendering matrices for arm bones
        UpdateMatrices(armChain, 0, armBoneThickness, handUp);
        int matrixIndex = armChain.Length - 1;

        // next:  fingers

        Vector3 handPos = armChain.Last();
        // fingers spread out during a throw
        float openPalm = throwCurve.Evaluate(throwTimer);

        for (int i = 0; i < fingerChains.Length; i++)
        {
            // find knuckle position for this finger
            Vector3 fingerPos = handPos + handRight * (fingerXOffset + i * fingerSpacing);

            // find resting position for this fingertip
            Vector3 fingerTarget = fingerPos + handForward * (.5f - .1f * fingerGrabT);

            // spooky finger wiggling while we're idle
            fingerTarget += handUp * Mathf.Sin((time + i * .2f) * 3f) * .2f * (1f - fingerGrabT);

            // if we're gripping, move this fingertip onto the surface of our rock
            Vector3 rockFingerDelta = fingerTarget - lastIntendedRockPos;
            Vector3 rockFingerPos   = lastIntendedRockPos + rockFingerDelta.normalized * (lastIntendedRockSize * .5f + fingerThicknesses[i]);
            fingerTarget = Vector3.Lerp(fingerTarget, rockFingerPos, fingerGrabT);

            // apply finger-spreading during throw animation
            fingerTarget += (handUp * .3f + handForward * .1f + handRight * (i - 1.5f) * .1f) * openPalm;

            // solve this finger's IK chain
            FABRIK.Solve(fingerChains[i], fingerBoneLengths[i], fingerPos, fingerTarget, handUp * fingerBendStrength);

            // update this finger's rendering matrices
            UpdateMatrices(fingerChains[i], matrixIndex, fingerThicknesses[i], handUp);
            matrixIndex += fingerChains[i].Length - 1;
        }

        // the thumb is pretty much the same as the fingers
        // (but pointing in a strange direction)
        Vector3 thumbPos    = handPos + handRight * thumbXOffset;
        Vector3 thumbTarget = thumbPos - handRight * .15f + handForward * (.2f + .1f * fingerGrabT) - handUp * .1f;

        thumbTarget += handRight * Mathf.Sin(time * 3f + .5f) * .1f * (1f - fingerGrabT);
        // thumb bends away from the palm, instead of "upward" like the fingers
        Vector3 thumbBendHint = (-handRight - handForward * .5f);

        Vector3 rockThumbDelta = thumbTarget - lastIntendedRockPos;
        Vector3 rockThumbPos   = lastIntendedRockPos + rockThumbDelta.normalized * (lastIntendedRockSize * .5f);

        thumbTarget = Vector3.Lerp(thumbTarget, rockThumbPos, fingerGrabT);

        FABRIK.Solve(thumbChain, thumbBoneLength, thumbPos, thumbTarget, thumbBendHint * thumbBendStrength);

        UpdateMatrices(thumbChain, matrixIndex, thumbThickness, thumbBendHint);

        // draw all of our bones
        Graphics.DrawMeshInstanced(boneMesh, 0, material, matrices);
    }
コード例 #51
0
ファイル: LGolem.cs プロジェクト: BenSchu438/CIS497-SPRING
 public LGolem()
 {
     child = new MBabies();
     noise = new Rock();
     name  = "large golem";
 }
コード例 #52
0
ファイル: Combat.cs プロジェクト: adepesters/GGJ2020
    void GenerateTerrain(int levelId)
    {
        _level_data = _levels[levelId];
        _board_size = (int)Mathf.Sqrt((float)_level_data.Length);
        _tile_count = _level_data.Length;

        if (_board_size * _board_size != _tile_count)
        {
            Debug.LogError("Damned, a non square level :(");
            this.enabled = false;
            return;
        }

        _selectionFrames = new SpriteRenderer[_tile_count];

        _grassTile.gameObject.SetActive(false);
        _waterTile.gameObject.SetActive(false);
        _rock.gameObject.SetActive(false);
        _column.gameObject.SetActive(false);
        _goal.gameObject.SetActive(false);
        _selectionFrame.gameObject.SetActive(false);

        Vector2 origin = new Vector2(-offset_w * (_board_size - 1), 0f);

        for (int tile_index = 0, y = 0; y < _board_size; y++)
        {
            for (int x = 0; x < _board_size; x++, tile_index++)
            {
                // each tile
                Vector2 pos       = GetTilePos(x, y);
                char    tile_char = GRASS; // default tile
                if (tile_index < _level_data.Length)
                {
                    tile_char = _level_data[tile_index];
                }
                if (tile_char != WATER)
                {
                    var tile = Instantiate(_grassTile, tiles_container);
                    tile.transform.localPosition = pos;
                    tile.gameObject.SetActive(true);
                }
                else
                {
                    var tile = Instantiate(_waterTile, tiles_container);
                    tile.transform.localPosition = pos;
                    tile.gameObject.SetActive(true);
                }

                if (tile_char == SPAWN)
                {
                    // friend robot
                    var robot_index = _craftingManager.RobotSlot[_currentSpawnRobotSlot];
                    if (robot_index != -1)
                    {
                        AddRobot(x, y, 2, friend: true, robot_index);
                        _currentSpawnRobotSlot++;
                    }
                }

                if (tile_char == ENEMY)
                {
                    AddRobot(x, y, 2, friend: false);
                }

                if (tile_char == ROCK)
                {
                    var rockView = Instantiate(_rock, tiles_container);
                    rockView.transform.localPosition = pos;
                    rockView.gameObject.SetActive(true);
                    var rock = new Rock();
                    rock.actor.x = x;
                    rock.actor.y = y;
                    rock.view    = rockView;
                    _rocks.Add(rock);
                }
                if (tile_char == COLUMN)
                {
                    var columnView = Instantiate(_column, tiles_container);
                    columnView.transform.localPosition = pos;
                    columnView.gameObject.SetActive(true);
                }
                if (tile_char == GOAL)
                {
                    var goal = Instantiate(_goal, tiles_container);
                    goal.transform.localPosition = pos;
                    goal.gameObject.SetActive(true);
                    _goal_actor            = new Actor();
                    _goal_actor.x          = x;
                    _goal_actor.y          = y;
                    _goal_actor.max_hp     = 2;
                    _goal_actor.current_hp = _goal_actor.max_hp;
                    _goal_actor.view       = goal.GetComponentInChildren <RobotView>();
                }
                var selectionFrame = Instantiate(_selectionFrame, tiles_container);
                selectionFrame.transform.localPosition = pos;
                selectionFrame.gameObject.SetActive(true);

                _selectionFrames[y * _board_size + x] = selectionFrame.GetComponent <SpriteRenderer>();
            }
        }
    }
コード例 #53
0
ファイル: MyGame.cs プロジェクト: Stepup2000/SlimeGame
    public void LoadLevel()
    {
        AddChild(new Sprite("Background.png"));
        paused = false;
        world  = new World();

        #region IMPORTANT SINGULAR OBJECTS
        player1 = new Player1();
        world.AddBody(player1);
        player1.SetPosition(64, 1024);

        player2 = new Player2();
        world.AddBody(player2);
        player2.SetPosition(128, 1024);

        Exit exit = new Exit();
        world.AddBody(exit);
        exit.SetPosition(1728, 128);

        Seed seed = new Seed(101);
        world.AddBody(seed);
        seed.SetPosition(1472, 1024);
        #endregion

        #region GATES+SAPLINGS
        // Vine gate (vertical, first floor, sample ID 8)
        Gate gate = new Gate(32, 96, 8);
        world.AddBody(gate);
        gate.SetPosition(448, 704);

        // "Corresponding" sapling
        Sapling sap = new Sapling(8);
        world.AddBody(sap);
        sap.SetPosition(768, 704);

        // Vine gate (horizontal ground floor, BUTTON)
        Gate gate0 = new Gate(96, 32, 101);
        world.AddBody(gate0);
        gate0.SetPosition(1792, 768);

        // Vine gate
        Gate gate1 = new Gate(32, 96, 9);
        world.AddBody(gate1);
        gate1.SetPosition(1152, 1024);

        // "Corresponding" sapling
        Sapling sap1 = new Sapling(9);
        sap1.rotation = 180;
        world.AddBody(sap1);
        sap1.SetPosition(960, 832);

        // Gate linked to spawnable sapling (ID 99)
        Gate sgate = new Gate(96, 32, 99);
        world.AddBody(sgate);
        sgate.SetPosition(256, 448);

        Gate sgate2 = new Gate(96, 32, 99);
        world.AddBody(sgate2);
        sgate2.SetPosition(64, 448);

        // Vine gate (FINAL, vertical)
        Gate gatef = new Gate(32, 96, 10);
        world.AddBody(gatef);
        gatef.SetPosition(1600, 128);

        // "Corresponding" sapling
        Sapling sapf = new Sapling(10);
        sapf.rotation = 90;
        world.AddBody(sapf);
        sapf.SetPosition(1600, 352);
        #endregion

        #region BUTTONS

        Button bseed = new Button(101, (int)Button.bType.SEED, "Soil.png");
        world.AddBody(bseed);
        bseed.SetPosition(1600, 1024);

        Button bslime = new Button(102, (int)Button.bType.SLIME, "Button.png");
        world.AddBody(bslime);
        bslime.SetPosition(64, 704);

        #endregion

        #region ROCKS
        // Top rock
        Rock rock = new Rock();
        world.AddBody(rock);
        rock.SetPosition(1856, 384);

        Rock rock2 = new Rock();
        world.AddBody(rock2);
        rock2.SetPosition(1024, 704);

        Rock rock3 = new Rock();
        world.AddBody(rock3);
        rock3.SetPosition(960, 1024);
        #endregion

        // Crystals
        #region CRYSTALS
        StaticCrystal sc = new StaticCrystal(170);
        sc.rotation = -260;
        world.AddBody(sc);
        sc.SetPosition(768, 512);

        StaticCrystal sc2 = new StaticCrystal(310);
        sc2.rotation = -400;
        world.AddBody(sc2);
        sc2.SetPosition(512, 576);

        StaticCrystal scleft = new StaticCrystal(80);
        scleft.rotation = -170;
        world.AddBody(scleft);
        scleft.SetPosition(64, 256);

        StaticCrystal scup1 = new StaticCrystal(258);
        scup1.rotation = -348;
        world.AddBody(scup1);
        scup1.SetPosition(768, 64);

        StaticCrystal scup2 = new StaticCrystal(260);
        scup2.rotation = -350;
        world.AddBody(scup2);
        scup2.SetPosition(1088, 64);

        StaticCrystal scr1 = new StaticCrystal(340);
        scr1.rotation = -430;
        world.AddBody(scr1);
        scr1.SetPosition(1600, 288);

        StaticCrystal scr2 = new StaticCrystal(185);
        scr2.rotation = -275;
        world.AddBody(scr2);
        scr2.SetPosition(1856, 256);
        #endregion


        //Walls
        #region WALLS/TILES
        //Ground floor floating wall1 (vertical)
        Tile tile1 = new Tile(19);
        world.AddBody(tile1);
        tile1.SetPosition(512, 928);
        Tile tile2 = new Tile(162);
        world.AddBody(tile2);
        tile2.SetPosition(512, 992);

        //Ground floor floating wall2 (vertical)
        Tile tile3 = new Tile(50);
        world.AddBody(tile3);
        tile3.SetPosition(1152, 832);
        Tile tile4 = new Tile(162);
        world.AddBody(tile4);
        tile4.SetPosition(1152, 896);

        //First floor floating wall (vertical)
        Tile tile5 = new Tile(47);
        world.AddBody(tile5);
        tile5.SetPosition(448, 512);
        Tile tile6 = new Tile(162);
        world.AddBody(tile6);
        tile6.SetPosition(448, 576);

        // First floor button gap wall (horizontal + block down)
        Tile tile7 = new Tile(124);
        world.AddBody(tile7);
        tile7.SetPosition(64, 608);
        Tile tile8 = new Tile(124);
        world.AddBody(tile8);
        tile8.SetPosition(128, 608);
        Tile tile9 = new Tile(53);
        world.AddBody(tile9);
        tile9.SetPosition(192, 608);

        //First floor second single wall
        Tile tileExtra = new Tile(19);
        world.AddBody(tileExtra);
        tileExtra.SetPosition(704, 704);

        Tile tileb = new Tile(162);
        world.AddBody(tileb);
        tileb.SetPosition(192, 672);

        Tile tilem = new Tile(19);
        world.AddBody(tilem);
        tilem.SetPosition(832, 704);

        //Second floor floating wall1 (vertical)
        Tile tile10 = new Tile(19);
        world.AddBody(tile10);
        tile10.SetPosition(448, 288);
        Tile tile11 = new Tile(162);
        world.AddBody(tile11);
        tile11.SetPosition(448, 352);

        //Second floor floating wall2 (horizontal)
        Tile tile12 = new Tile(123);
        world.AddBody(tile12);
        tile12.SetPosition(384, 128);
        Tile tile13 = new Tile(124);
        world.AddBody(tile13);
        tile13.SetPosition(448, 128);
        Tile tile14 = new Tile(44);
        world.AddBody(tile14);
        tile14.SetPosition(512, 128);

        //Second floor floating wall3 (horizontal)
        Tile tile15 = new Tile(123);
        world.AddBody(tile15);
        tile15.SetPosition(704, 256);
        Tile tile16 = new Tile(44);
        world.AddBody(tile16);
        tile16.SetPosition(768, 256);

        //Second floor floating wall4 (horizontal)
        Tile tile17 = new Tile(123);
        world.AddBody(tile17);
        tile17.SetPosition(1280, 256);
        Tile tile18 = new Tile(44);
        world.AddBody(tile18);
        tile18.SetPosition(1344, 256);

        //Second floor floating wall5 (vertical)
        Tile tile19 = new Tile(19);
        world.AddBody(tile19);
        tile19.SetPosition(1536, 288);
        Tile tile20 = new Tile(162);
        world.AddBody(tile20);
        tile20.SetPosition(1536, 352);


        //Second floor ending platform (horizontal)
        Tile tile21 = new Tile(123);
        world.AddBody(tile21);
        tile21.SetPosition(1600, 192);
        Tile tile22 = new Tile(124);
        world.AddBody(tile22);
        tile22.SetPosition(1664, 192);
        Tile tile23 = new Tile(124);
        world.AddBody(tile23);
        tile23.SetPosition(1728, 192);
        Tile tile24 = new Tile(124);
        world.AddBody(tile24);
        tile24.SetPosition(1792, 192);
        Tile tile25 = new Tile(124);
        world.AddBody(tile25);
        tile25.SetPosition(1856, 192);


        //Ground floor platform
        Tile tile26 = new Tile(123);
        world.AddBody(tile26);
        tile26.SetPosition(1856, 896);


        //Floors
        //First floor
        for (int i = 0; i < 27; i++)
        {
            Tile tile = new Tile(41);
            world.AddBody(tile);
            tile.SetPosition(i * 64, 768);
        }

        //Second floor
        for (int i = 0; i < 25; i++)
        {
            Tile tile = new Tile(41);
            world.AddBody(tile);
            tile.SetPosition((i * 64) + 384, 448);
        }

        //Boundary
        //Ceiling
        for (int i = 0; i < 31; i++)
        {
            Tile tile = new Tile(30);
            world.AddBody(tile);
            tile.SetPosition(i * 64, 0);
        }

        //Floor
        for (int i = 0; i < 31; i++)
        {
            Tile tile = new Tile(227);
            world.AddBody(tile);
            tile.SetPosition(i * 64, 1088);
        }

        //Left
        for (int i = 0; i < 17; i++)
        {
            Tile tile = new Tile(57);
            world.AddBody(tile);
            tile.SetPosition(0, i * 64);
        }

        //Right
        for (int i = 0; i < 17; i++)
        {
            Tile tile = new Tile(64);
            world.AddBody(tile);
            tile.SetPosition(game.width, i * 64);
        }

        //Left bottom corner
        Tile tile27 = new Tile(225);
        world.AddBody(tile27);
        tile27.SetPosition(0, 1088);
        //Right bottom corner
        Tile tile28 = new Tile(232);
        world.AddBody(tile28);
        tile28.SetPosition(1920, 1088);
        //Right top corner
        Tile tile29 = new Tile(36);
        world.AddBody(tile29);
        tile29.SetPosition(1920, 0);
        //Left top corner
        Tile tile30 = new Tile(29);
        world.AddBody(tile30);
        tile30.SetPosition(0, 0);

        //Ground floor right side
        Tile tile31 = new Tile(128);
        world.AddBody(tile31);
        tile31.SetPosition(1920, 896);
        //First floor ground
        Tile tile32 = new Tile(44);
        world.AddBody(tile32);
        tile32.SetPosition(1664, 768);
        //First floor intersection 1
        Tile tile33 = new Tile(81);
        world.AddBody(tile33);
        tile33.SetPosition(1152, 768);
        //First floor intersection 2
        Tile tile34 = new Tile(109);
        world.AddBody(tile34);
        tile34.SetPosition(832, 768);
        //First floor left border
        Tile tile35 = new Tile(39);
        world.AddBody(tile35);
        tile35.SetPosition(0, 768);
        //First floor left border
        Tile tile36 = new Tile(39);
        world.AddBody(tile36);
        tile36.SetPosition(0, 608);
        //Second floor first intersection
        Tile tile37 = new Tile(81);
        world.AddBody(tile37);
        tile37.SetPosition(448, 448);
        //Second floor begin ground
        Tile tile37v = new Tile(123);
        world.AddBody(tile37v);
        tile37v.SetPosition(328, 448);
        //Second floor ground intersection right
        Tile tile38 = new Tile(128);
        world.AddBody(tile38);
        tile38.SetPosition(1920, 448);
        //Second floor platform intersection right
        Tile tile39 = new Tile(128);
        world.AddBody(tile39);
        tile39.SetPosition(1920, 192);

        //First floor second single wall intersection
        Tile tile40 = new Tile(109);
        world.AddBody(tile40);
        tile40.SetPosition(704, 768);
        #endregion

        #region UI/BUTTONS
        /*AddChild(new Sprite("StripInGame.png"));*/
        button1 = new Sprite("Shrink.png");
        AddChild(button1);
        button1.SetXY(25, 12);
        button2 = new Sprite("Grow.png");
        AddChild(button2);
        button2.SetXY(145, 12);
        button3 = new Sprite("RotatePhysicalSlime.png");
        AddChild(button3);
        button3.SetXY(265, 12);
        button4 = new Sprite("RotateLightSlime.png");
        AddChild(button4);
        button4.SetXY(1580, 12);
        button5 = new Sprite("InvertGravity.png");
        AddChild(button5);
        button5.SetXY(1700, 12);
        button6 = new Sprite("LightBeamButton.png");
        AddChild(button6);
        button6.SetXY(1820, 12);
        #endregion
    }
コード例 #54
0
        public GameDisplay()
        {
            // Initialize the player class
            player = new Player();

            // Create wave 1
            CreateWave(1, () =>
            {
                //Adds 1 item into the item list
                Item iT = new Item(Game1.GAME.GraphicsDevice.Viewport.Width / 2, Game1.GAME.GraphicsDevice.Viewport.Height / 2);
                iT.Initialize(ItemT);
                item.Add(iT);
                //Adds 5 enemies into the enemy list
                for (int i = 0; i < 5; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - 60, EnemyT);
                    entities.Add(e);
                }

                //Adds 5 rocks into the rocks list
                for (int i = 0; i < 5; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Rock r  = new Rock(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 100, RockT);
                    Rock r2 = new Rock(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - (i * -100 + 500), RockT);
                    rocks.Add(r);
                    rocks.Add(r2);
                }
            }, () => {
                BG = Game1.GAME.Content.Load <Texture2D>("Assets\\Room2");
            });

            CreateWave(2, () =>
            {
                //Stpres the players current speed
                playerspeed = player.playerMoveSpeed;
                //When the next wave is initiated if the item exists the item is removed
                for (int i = 0; i < item.Count; i++)
                {
                    foreach (Item iTE in item)
                    {
                        iTE.isPicked = true;
                    }
                }

                Item iT = new Item(Game1.GAME.GraphicsDevice.Viewport.Width / 2, Game1.GAME.GraphicsDevice.Viewport.Height / 2);
                iT.Initialize(Item2T);
                item.Add(iT);


                //Adds 5 enemies into the enemy list
                for (int i = 0; i < 5; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 60, EnemyT);
                    entities.Add(e);
                }


                //Kills all rocks from previous wave
                for (int i = 0; i < rocks.Count; i++)
                {
                    foreach (Rock r in rocks)
                    {
                        r.isDead = true;
                    }
                }

                for (int i = 0; i < 5; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Rock r = new Rock(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 100, RockT);
                    rocks.Add(r);
                }

                if (player1)
                {
                    player.PlayerTexture = Game1.GAME.Content.Load <Texture2D>("Assets\\p2SS");
                }
                player.Health += 20;
                player.hasItem = false;
            }, () => {
                BG = Game1.GAME.Content.Load <Texture2D>("Assets\\Room3");
            });

            CreateWave(3, () =>
            {
                //Resets the player move speed if an item has been picked up
                player.playerMoveSpeed = playerspeed;

                //Adds 7 enemies into the enemy list
                for (int i = 0; i < 7; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 20, EnemyT);
                    entities.Add(e);
                }

                for (int i = 0; i < rocks.Count; i++)
                {
                    foreach (Rock r in rocks)
                    {
                        r.isDead = true;
                    }
                }

                for (int i = 0; i < 5; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Rock r = new Rock(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - (i * -100 + 500), RockT);
                    rocks.Add(r);
                }
                foreach (Enemy e in entities)
                {
                    e.Health     = 110;
                    e.rateOfFire = 5;
                    e.eVelocity *= 1.5f;
                }
                player.Health += 20;
                if (player1)
                {
                    player.PlayerTexture = Game1.GAME.Content.Load <Texture2D>("Assets\\p2SS");
                }
                player.hasItem = false;
            }, () => {
                BG = Game1.GAME.Content.Load <Texture2D>("Assets\\Room4");
            });

            CreateWave(4, () =>
            {
                Item iT = new Item((Game1.GAME.GraphicsDevice.Viewport.Width / 2) - 150, (Game1.GAME.GraphicsDevice.Viewport.Height / 2) + 50);
                iT.Initialize(Item3T);
                item.Add(iT);

                //Adds 5 enemies into the enemy list
                for (int i = 0; i < 5; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 10, EnemyT);
                    entities.Add(e);
                }
                foreach (Enemy e in entities)
                {
                    e.Health     = 120;
                    e.eVelocity /= 2;
                    e.rateOfFire = 1;
                }
                if (player1)
                {
                    player.PlayerTexture = Game1.GAME.Content.Load <Texture2D>("Assets\\p2SS");
                }
                player.playerDamage = 40;
                player.Health      += 20;
                player.hasItem      = false;
            }, () => { });

            CreateWave(5, () =>
            {
                //Resets the player move speed if an item has been picked up
                player.playerMoveSpeed = playerspeed;

                //Adds 7 enemies into the enemy list
                for (int i = 0; i < 7; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 10, EnemyT);
                    entities.Add(e);
                }
                //Increases the health of all enemies this wave
                foreach (Enemy e in entities)
                {
                    e.Health = 130;
                }
                if (player1)
                {
                    player.PlayerTexture = Game1.GAME.Content.Load <Texture2D>("Assets\\p2SS");
                }
                player.Health += 20;
                player.hasItem = false;
            }, () => { });

            CreateWave(6, () =>
            {
                //Adds 7 enemies into the enemy list
                for (int i = 0; i < 7; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 10, EnemyT);
                    entities.Add(e);
                }
                foreach (Enemy e in entities)
                {
                    e.Health = 140;
                }
                if (player1)
                {
                    player.PlayerTexture = Game1.GAME.Content.Load <Texture2D>("Assets\\p2SS");
                }
                player.Health += 20;
            }, () => { });

            CreateWave(7, () =>
            {
                //Adds 8 enemies into the enemy list
                for (int i = 0; i < 8; i++)
                {
                    //Sets the X&Y-Co-ordinate within the game viewport at a proportional gradient
                    Enemy e = new Enemy(Game1.GAME.GraphicsDevice.Viewport.Width - (i + 1) * 125, Game1.GAME.GraphicsDevice.Viewport.Height - i * 10, EnemyT);
                    entities.Add(e);
                }
                foreach (Enemy e in entities)
                {
                    e.Health = 150;
                }
                if (player1)
                {
                    player.PlayerTexture = Game1.GAME.Content.Load <Texture2D>("Assets\\p2SS");
                }
                player.Health += 20;
            }, () => { });
        }