Inheritance: MonoBehaviour
Beispiel #1
0
 public void OnUpdateEggs(JsonData jd)
 {
     Global.eggs = Egg.ParseEggs(jd["Eggs"]);
     foreach (Egg egg in Global.eggs)
     {
         Debug.Log(egg.ToString());
     }
 }
Beispiel #2
0
        public string AddEgg(string eggName, int energyRequired)
        {
            var egg = new Egg(eggName, energyRequired);

            this.eggRepository.Add(egg);

            return(string.Format(OutputMessages.EggAdded, eggName));
        }
Beispiel #3
0
 public bool IsInherited(int m)
 {
     if (Base.Contains(m))
     {
         return(false);
     }
     return(Special.Contains(m) || Egg.Contains(m) || LevelUp.Contains(m) || TMHM.Contains(m) || Tutor.Contains(m));
 }
 //called from multithreaded enviorment
 public void Delete(Egg egg)
 {
     using (ApplicationDBContext context = new ApplicationDBContext())
     {
         context.Eggs.Remove(egg);
         context.SaveChanges();
     }
 }
Beispiel #5
0
        public string AddEgg(string eggName, int energyRequired)
        {
            IEgg egg = new Egg(eggName, energyRequired);

            eggs.Add(egg);

            return($"Successfully added egg: {eggName}!");
        }
Beispiel #6
0
    void OnCollisionEnter2D(Collision2D other)
    {
        Assert.AreEqual(other.gameObject.layer, LayerMask.NameToLayer("Egg"));
        Egg egg = other.gameObject.GetComponent <Egg>();

        Assert.IsNotNull(egg);
        onEggFallOut.Invoke(egg);
    }
Beispiel #7
0
        /// <summary>
        /// 装饰者模式
        /// </summary>
        public static void DecoratorPatternMethods()
        {
            var noodles = new YouPoNoodles();
            var egg     = new Egg(noodles);
            var lajiao  = new LaJiao(egg);

            lajiao.AddSomeThing();
        }
 public static Egg GetInstance()
 {
     if (instance == null)
     {
         instance = new Egg();
     }
     return(instance);
 }
Beispiel #9
0
        public void FighterFactory_CorrectlyRandomizesEggType_IfNoneSpecified()
        {
            TestFighterFactory.SetChanceService(_chanceService);
            _chanceService.PushWhichEventOccurs(0);

            Egg egg = (Egg)FighterFactory.GetFighter(FighterType.Egg, 1);

            Assert.AreEqual(Globals.EggMagicTypes[0], egg.MagicType);
        }
Beispiel #10
0
 public IActionResult Create([FromBody] Egg egg)
 {
     if (egg == null)
     {
         return(BadRequest());
     }
     eggsRep.Create(egg);
     return(CreatedAtRoute("GetEggFromAll", new { id = egg.Id }, egg));
 }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Egg e = collision.gameObject.GetComponent <Egg>();

        if (e != null)
        {
            boss.TakeDamage(1);
        }
    }
Beispiel #12
0
        public string AddEgg(string eggName, int energyRequired)
        {
            string message = string.Empty;
            var    egg     = new Egg(eggName, energyRequired);

            eggRepository.Add(egg);
            message = string.Format(OutputMessages.EggAdded, eggName);
            return(message);
        }
Beispiel #13
0
    public void UseSkill()
    {
        Egg egg = MonoBehaviour.Instantiate(_eggPrefab).GetComponent <Egg>();

        egg.SetEggDamage(_eggDamage);
        view.PlayEggSound();
        egg.transform.position = _eggSpawnPoint.position;
        egg.GetComponent <Rigidbody2D>().AddForce(new Vector2(_eggSpawnPoint.right.x, 1).normalized *_throwForce, ForceMode2D.Impulse);
    }
Beispiel #14
0
        public Egg Create(int id)
        {
            Chicken chicken = Context.Chickens.Find(id);
            Egg     egg     = chicken.CreateChild();

            Context.Eggs.Add(egg);
            Context.SaveChanges();
            return(egg);
        }
Beispiel #15
0
 public static Egg[] FryEggs(int egg)
 {
     Egg[] eggs = new Egg[egg];
     for (int i = 0; i < egg; i++)
     {
         eggs[i] = new Egg();
     }
     return(eggs);
 }
Beispiel #16
0
 void Start()
 {
     Screen.SetResolution(1200, 675, true, 60);
     player    = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     egg       = GameObject.FindGameObjectWithTag("Egg").GetComponent <Egg>();
     showScore = (Text)GameObject.FindGameObjectWithTag("Score").GetComponent <Text>();
     showEggHP = (Text)GameObject.FindGameObjectWithTag("EggHP").GetComponent <Text>();
     showLevel = (Text)GameObject.FindGameObjectWithTag("Level").GetComponent <Text>();
 }
Beispiel #17
0
        private void EggRemove(object sender, EventArgs e)
        {
            Egg eg = sender as Egg;

            foreach (Image im in eg.EggWay)
            {
                MainGrid.Children.Remove(im);
            }
        }
        public void CorrectlyMovesToNextSubRegion_OnlyOneNextSubRegion()
        {
            const MagicType firstBossEggType  = MagicType.Fire;
            const MagicType secondBossEggType = MagicType.Ice;

            TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType));
            SubRegion         subRegionA             = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration));

            const string      secondRegionIntro       = "Who wants donuts?!?";
            TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType));
            SubRegion         subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration), regionIntro: secondRegionIntro);

            SubRegion[] subRegions = { subRegionA, subRegionB };

            Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions);

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion));

            AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB));

            _mapManager.SetRegionalMap(regionMap);
            _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap);

            _regionManager = GetRegionManager();

            TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            target.SetHealth(1, 0);

            _humanFighter1.SetMove(_basicAttackMove, 1);
            _humanFighter1.SetMove(_runawayMove, 1);
            _humanFighter1.SetMoveTarget(target);

            _humanFighter2.SetMove(_doNothingMove);

            _chanceService.PushAttackHitsNotCrit();

            _regionManager.Battle(_battleManager, _humanTeam);

            MockOutputMessage[] outputs = _output.GetOutputs();

            Assert.NotNull(outputs.FirstOrDefault(o => o.Message == secondRegionIntro + "\n"));

            List <Team> enemyTeams = _battleManager.GetAllEnemyTeams();

            Assert.AreEqual(2, enemyTeams.Count);

            Egg secondBoss = enemyTeams[1].Fighters[0] as Egg;

            Assert.NotNull(secondBoss);
            Assert.AreEqual(secondBossEggType, secondBoss.MagicType);

            Assert.AreEqual(WorldSubRegion.DesertCrypt, subRegionMap.CurrentArea.AreaId);
        }
Beispiel #19
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && isFlying && eggCount-- > 0)
     {
         Vector3 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
         Egg     egg       = Instantiate(eggGO, transform.position + direction.normalized * EGG_DISTANCE, Quaternion.identity).GetComponent <Egg>();
         egg.Push(EGG_FORCE * RB.mass * direction, ForceMode2D.Impulse);
         RB.AddForce(EGG_FORCE * RB.mass * -direction, ForceMode2D.Impulse);
     }
 }
    void Awake()
    {
        canResetBall    = true;
        ballRb          = egg.GetComponent <Rigidbody>();
        mBall           = egg.GetComponent <Egg>();
        mBall.area      = this;
        ballStartingPos = egg.transform.position;

        m_ResetParams = Academy.Instance.EnvironmentParameters;
    }
Beispiel #21
0
    public void RemoveUnlaidPlayerEgg()
    {
        // Do a direct access of the eggs array because GetEgg() screens out eggs which aren't laid
        Egg egg = this.eggs[(int)Side.Player];

        if (egg && egg.IsFullyGrown == false)
        {
            this.gameManager.PlayerSnake.Tail.RemoveEgg();
        }
    }
    private void EggSpawn()
    {
        float eggSize  = Random.Range(eggMinSize, eggMaxSize);
        Egg   eggClone = (Egg)Instantiate(eggPrefab, transform.position, transform.rotation);

        eggClone.transform.SetParent(EggParent.transform);
        eggClone.transform.localPosition = new Vector3(Random.Range(xMinPos, xMaxPos), EggParent.transform.position.y, 0f);
        eggClone.transform.localScale    = new Vector3(eggSize, eggSize, 0);
        eggClone.GetComponent <Rigidbody2D>().velocity = new Vector2(0, Random.Range(eggRandomMin, eggRandomMax));
    }
Beispiel #23
0
    private void OnTriggerEnter(Collider other)
    {
        Egg egg = other.gameObject.GetComponent <Egg>();

        if (egg)
        {
            Destroy(other.gameObject);
            gameEngine.SellEgg();
        }
    }
        public string AddEgg(string eggName, int energyRequired)
        {
            IEgg egg = new Egg(eggName, energyRequired);

            this.eggs.Add(egg);

            var result = String.Format(OutputMessages.EggAdded, eggName);

            return(result);
        }
Beispiel #25
0
        public void Setup()
        {
            _chanceService = new MockChanceService();

            _egg1 = new Egg(MagicType.Fire);
            _egg2 = new Egg(MagicType.Fire);
            _egg3 = new Egg(MagicType.Fire);

            _enemyTeam = new Team(TestMenuManager.GetTestMenuManager(), _egg1, _egg2, _egg3);
        }
Beispiel #26
0
    public void EggDied(string[] res)
    {
        if (res.Length == 2)
        {
            Egg egg = spawnManager.FindEggById(int.Parse(res[1]));

            spawnManager.eggs.Remove(egg);
            Destroy(egg.gameObject);
        }
    }
Beispiel #27
0
    public void SpawnEgg(Vector2 pos, int id, string team)
    {
        GameObject go     = Instantiate(eggPrefab, map.GetRandomCasePos((int)pos.x, (int)pos.y) + new Vector3(0, 0.5f, 0), eggPrefab.transform.rotation, eggRoot);
        Egg        newEgg = go.GetComponent <Egg>();

        newEgg.id   = id;
        newEgg.team = team;
        eggs.Add(newEgg);
        newEgg.Pop();
    }
        public static void FindEggToGuard(List <UpdateBucketWithUpdater <Instance> .Entry> instances, float time_delta)
        {
            ListPool <KPrefabID, EggProtectionMonitor> .PooledList pooledList = ListPool <KPrefabID, EggProtectionMonitor> .Allocate();

            pooledList.Capacity = Mathf.Max(pooledList.Capacity, Components.Pickupables.Count);
            IEnumerator enumerator = Components.Pickupables.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Pickupable pickupable = (Pickupable)enumerator.Current;
                    pooledList.Add(pickupable.gameObject.GetComponent <KPrefabID>());
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            ListPool <Egg, EggProtectionMonitor> .PooledList pooledList2 = ListPool <Egg, EggProtectionMonitor> .Allocate();

            find_eggs_job.Reset(pooledList);
            for (int i = 0; i < pooledList.Count; i += 256)
            {
                find_eggs_job.Add(new FindEggsTask(i, Mathf.Min(i + 256, pooledList.Count)));
            }
            GlobalJobManager.Run(find_eggs_job);
            for (int j = 0; j != find_eggs_job.Count; j++)
            {
                find_eggs_job.GetWorkItem(j).Finish(pooledList, pooledList2);
            }
            pooledList.Recycle();
            foreach (UpdateBucketWithUpdater <Instance> .Entry instance in instances)
            {
                UpdateBucketWithUpdater <Instance> .Entry current = instance;
                GameObject eggToGuard = null;
                int        num        = 100;
                foreach (Egg item in pooledList2)
                {
                    Egg current2       = item;
                    int navigationCost = current.data.navigator.GetNavigationCost(current2.cell);
                    if (navigationCost != -1 && navigationCost < num)
                    {
                        eggToGuard = current2.game_object;
                        num        = navigationCost;
                    }
                }
                current.data.SetEggToGuard(eggToGuard);
            }
            pooledList2.Recycle();
        }
Beispiel #29
0
    public override void OnDestroy()
    {
        base.OnDestroy();

        // If a snake dies, partway through laying an egg, we need to destroy the egg object too.
        if (this.Egg != null)
        {
            this.Egg.Die();
            this.Egg = null;
        }
    }
Beispiel #30
0
    public void BeginToCreateEgg(Egg egg)
    {
        egg.SetParent(this);

        // Make sure egg is displayed on top of the segment
        egg.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
        egg.SetSpriteDepth(GetSpriteDepth() + 1);

        this.Egg        = egg;
        egg.FullyGrown += this.EggFullyGrown;
    }
Beispiel #31
0
        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates)
        {
            float force = 1.5f;

            Egg egg = new Egg(player, world);
            egg.KnownPosition = (PlayerLocation) player.KnownPosition.Clone();
            egg.KnownPosition.Y += 1.62f;
            egg.Velocity = egg.KnownPosition.GetDirection()*(force);
            egg.BroadcastMovement = false;
            egg.DespawnOnImpact = true;
            egg.SpawnEntity();
        }
Beispiel #32
0
        //--------------------------------------------------------------------
        // Constructor
        //--------------------------------------------------------------------
        internal Queen()
        {
            m_alien_color = Color.White;
            m_restitution = 2f;
            for ( int i = 0; i < 4; i++ ) {
                eggs[i] = new Egg();
                eggs[i].intact = true;
                eggs[i].pos = Vector2.Zero;
            }

            eggs[0].pos += new Vector2( 9, -4 );
            eggs[0].angle = 1.35f;
            eggs[1].pos += new Vector2( 7, -10 );
            eggs[1].angle = 0.65f;

            eggs[2].pos += new Vector2( -9, -4 );
            eggs[2].angle = -1.35f;
            eggs[3].pos += new Vector2( -7, -10 );
            eggs[3].angle = -0.65f;
        }
Beispiel #33
0
        public Queen( GameWorld world, Texture2D texture, Vector2 position, float size,
            AlienType type, int cooldown, String texturename = TNames.queen_alien, int max_spawn = 10 )
            : base(world, texture, position, size,
            type, cooldown, texturename: texturename, max_spawn: max_spawn, ai: AlienController.AIType.BOSS, patrol: 0.03f)
        {
            m_alien_color = Color.White;
            m_restitution = 2f;
            for ( int i = 0; i < 4; i++ ) {
                eggs[i] = new Egg();
                eggs[i].intact = true;
                eggs[i].pos = Vector2.Zero;
            }

            eggs[0].pos += new Vector2( 9, -4 );
            eggs[0].angle = 1.35f;
            eggs[1].pos += new Vector2( 7, -10 );
            eggs[1].angle = 0.65f;

            eggs[2].pos += new Vector2( -9, -4 );
            eggs[2].angle = -1.35f;
            eggs[3].pos += new Vector2( -7, -10 );
            eggs[3].angle = -0.65f;
        }
Beispiel #34
0
        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates)
        {
            if (player.GameMode != GameMode.Creative)
            {
                Item itemStackInHand = player.Inventory.GetItemInHand();
                itemStackInHand.Count--;

                if (itemStackInHand.Count <= 0)
                {
                    // set empty
                    player.Inventory.Slots[player.Inventory.Slots.IndexOf(itemStackInHand)] = new ItemAir();
                }
            }

            float force = 1.5f;

            Egg egg = new Egg(player, world);
            egg.KnownPosition = (PlayerLocation) player.KnownPosition.Clone();
            egg.KnownPosition.Y += 1.62f;
            egg.Velocity = egg.KnownPosition.GetDirection()*(force);
            egg.BroadcastMovement = false;
            egg.DespawnOnImpact = true;
            egg.SpawnEntity();
        }
Beispiel #35
0
 // Constructor
 protected void Awake()
 {
     egg = gameObject.GetComponentInChildren<Egg>();
 }
	// Use this for initialization
	void Start () {

		lifeCounter = lifeStarting;
		player = FindObjectOfType<Egg> ();
	}
 public CupWithEgg()
 {
     Egg = new Egg();
 }