コード例 #1
0
        public static void Main(string[] args)
        {
            var me  = Person.GetByReference("me");
            var you = Person.GetByReference("you");

            while (me.DoThinkAbout(you))
            {
                if (Calendar.Today.CelebratedProfession == you.Profession)
                {
                    try
                    {
                        Collection <Skill> myMainSkill = me
                                                         .Skills
                                                         .OrderByDescending(s => s.Profficency)
                                                         .First();

                        Collection <Feeling> myMotivation = me.GetFeelings(you);

                        Gift myGift = GiftFactory
                                      .CreateGiftAsync(me, myMainSkill, myMotivation)
                                      .Result;

                        bool giftAccepted = myGift
                                            .SendToAsync(you)
                                            .Result;

                        if (giftAccepted)
                        {
                            foreach (var feeling in me.GetFeelings(you))
                            {
                                // TODO: remove validation
                                if (!feeling.IsRated)
                                {
                                    Console.WriteLine(feeling);
                                }
                            }
                        }
                        else
                        {
                            myGift.Destroy();
                        }
                    } // Do I need to explain what I mean with "available"?
                    catch (PersonNotAvailableException ex)
                    {
                        // May throw InvalidOperationException
                        me.Ideas
                        .RemoveAll(i => i.Contains(you));
                    }
                }
            }
        }
コード例 #2
0
        private void Initialize()
        {
            this.player = new Santa(100, 10, "Pesho");

            this.giftFactory  = new GiftFactory();
            this.enemyFactory = new EnemyFactory();

            this.giftFactory.Produce(this.levelManager.CurrentLevel.Tiles);
            this.enemyFactory.Produce(this.levelManager.CurrentLevel.Tiles);

            foreach (var generatedeEnemy in this.enemyFactory.GeneratedeEnemies)
            {
                generatedeEnemy.Killed += EnemyKilled;
            }

            this.player.Position = new Vector2(Constants.PlayerSpawnPoint, Constants.PlayerSpawnPoint);

            this.font     = this.Content.Load <SpriteFont>("Fonts/mainMenu");
            this.SideMenu = this.Content.Load <Texture2D>("Images/Backgrounds/SideMenu");

            this.MapViewport = new Viewport
            {
                X        = 420,
                Y        = 0,
                Width    = this.Graphics.PreferredBackBufferHeight,
                Height   = this.Graphics.PreferredBackBufferHeight,
                MinDepth = 0,
                MaxDepth = 1
            };

            this.MenuViewport = new Viewport
            {
                X        = this.Graphics.PreferredBackBufferHeight + 420,
                Y        = 0,
                Width    = this.Graphics.PreferredBackBufferWidth - this.Graphics.PreferredBackBufferHeight,
                Height   = this.Graphics.PreferredBackBufferHeight,
                MinDepth = 0,
                MaxDepth = 1
            };

            this.InventoryViewport = new Viewport
            {
                X        = 0,
                Y        = 0,
                Width    = 420,
                Height   = this.Graphics.PreferredBackBufferHeight,
                MinDepth = 0,
                MaxDepth = 1
            };
        }
コード例 #3
0
ファイル: BlockScript.cs プロジェクト: ArpitKhare/Arkanoid
	void OnCollisionEnter2D(Collision2D collision){

		if (collision.gameObject.tag == "ball"){
			numberOfHits++;
			
			if (numberOfHits == hitsToKill){
				// get reference of player object
				GameObject player = GameObject.FindGameObjectsWithTag("player")[0];
				getBlockPosition = transform.position;
				//Prints the position to the Console.
				getBlockName= this.gameObject.name;
				GiftFactory GiftFactory = new GiftFactory();
				GameObject g = GiftFactory.getGift(this.gameObject);
				GameObject gift = (GameObject)Instantiate(g, new Vector3(getBlockPosition.x, getBlockPosition.y, getBlockPosition.z), Quaternion.identity);
				player.SendMessage("addPoints", points);

				// destroy the object
				Destroy(this.gameObject);
			}
		}
	}
コード例 #4
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "ball")
        {
            numberOfHits++;

            if (numberOfHits == hitsToKill)
            {
                // get reference of player object
                GameObject player = GameObject.FindGameObjectsWithTag("player")[0];
                getBlockPosition = transform.position;
                //Prints the position to the Console.
                getBlockName = this.gameObject.name;
                GiftFactory GiftFactory = new GiftFactory();
                GameObject  g           = GiftFactory.getGift(this.gameObject);
                GameObject  gift        = (GameObject)Instantiate(g, new Vector3(getBlockPosition.x, getBlockPosition.y, getBlockPosition.z), Quaternion.identity);
                player.SendMessage("addPoints", points);

                // destroy the object
                Destroy(this.gameObject);
            }
        }
    }