상속: MonoBehaviour
예제 #1
0
    public override void Execute(Bird owner)
    {
        if (owner.Information.Count == 0 || !owner.Hungry)
        {
            owner.ChangeState(owner.StateExplore);
        }

        feedStateTimer += Time.deltaTime;
        // delete information if it is wrong
        if (Vector3.Distance(owner.transform.position, owner.targetPoint) <=
            Bird.settings.feed_discreditInfoDistance ||
            feedStateTimer >= Bird.settings.feed_discreditInfoAfterTimeInState)
        {
            if (owner.Hungry)
            {
                owner.DiscreditFoodAt(owner.targetPoint);

                if (owner.Information.Count > 0)
                {
                    owner.targetPoint = ChooseFoodSource(owner);
                }
                else
                {
                    owner.ChangeState(owner.StateExplore);
                }
            }
            else
            {
                owner.ChangeState(owner.StateExplore);
            }
        }
    }
    // Built-in Functions
    void Awake()
    {
        bird = GetComponent<Bird>();
        radius = GetComponent<CircleCollider2D>().radius;

        currentState = PredictJumpDistance;
    }
예제 #3
0
파일: Program.cs 프로젝트: 3A9C/ITstep
        static void Main(string[] args)
        {
            Animal[] animals = new Animal[5];

            animals[0] = new Cat("KUZYA");
            animals[1] = new Bird("GOSHA");
            animals[2] = new Bird("CARCUSHA");
            animals[3] = new Cat("NUSHA");
            animals[4] = new Bird("VASILIY");


            foreach (var an in animals)
            {
                try
                {
                    IFlier f = (IFlier)an;
                    f.Fly();
                }
                catch (InvalidCastException)
                {
                    // nothing
                }
            }
            Console.ReadKey();
        }
예제 #4
0
	private Shot Solve(Bird currentBird, Pig targetPig, Vector2 slingPos) 
	{
		// 1. Random pick up a pig
		Vector2 shotPos = targetPig.transform.position;
		
		// 2. If the target is very close to before, randomly choose a point near it
		if(_lastTargetPig != null && _lastTargetPig == targetPig)
		{
			float angle = Random.value * Mathf.PI * 2f;
			if(Random.value < 0.5)
				angle *= -1f;

			shotPos.x = shotPos.x + Mathf.Cos(angle) * 0.5f;
			shotPos.y = shotPos.y + Mathf.Cos(angle) * 0.5f;
		}
		
		_lastTargetPig = targetPig;
		
		// 3. Estimate the trajectory
		float birdVel = currentBird._launchForce.x * -2f;
		float birdGrav =  currentBird._launchGravity * Physics2D.gravity.y;

		Vector2 releasePoint = TrajectoryPlanner.estimateLaunchPoint(slingPos, shotPos, birdVel, birdGrav);

		// 5. Calculate the tapping time according the bird type 	
		return new Shot(slingPos.x, slingPos.y, releasePoint.x, releasePoint.y, 0.5f);
	}
예제 #5
0
 static void Main(string[] args)
 {
     Bird myBird = new Bird();
     myBird.Tweet();
     Doggy myDog = new Doggy();
     myDog.Woof();
 }
예제 #6
0
 // Use this for initialization
 void Awake()
 {
     Bird.Instance = this;
     Tips = GameObject.Find ("Tips");
     GameOver = GameObject.Find ("GameOver");
     GameOver.SetActive (false);
 }
예제 #7
0
파일: SceneT14.cs 프로젝트: Otto404/wp-xna
        public override void LoadContent( )
        {
            base.LoadContent ( );

            this.bird = new Bird ( this, new Vector2 ( 200, 100 ) );

            this.world.Components.Add ( this.bird );
        }
예제 #8
0
 public void FoundFood(Bird owner)
 {
     // hungry -> feed
     if (owner.Hungry)
     {
         owner.ChangeState(owner.StateFeed);
     }
 }
예제 #9
0
    /**
     * @fn Awake
     * @biref コンストラクタ的な関数
     */
    void Awake()
    {
        // このオブジェクトを消さないようにする
        DontDestroyOnLoad(gameObject);

        // 鳥クラスを取得する
        bird = GetComponent<Bird>();
    }
예제 #10
0
파일: Bird.cs 프로젝트: dashqasar/2D-Game
    // Awake is called when the script instance is being loaded
    void Awake()
    {
        instance = this;
        initPos = transform.position;
        thisAnimator = GetComponent<Animator>();

        Onetime = true;
    }
예제 #11
0
    /// <summary>
    /// Adds a bird to this state and to its enclosing flock.
    /// </summary>
    public virtual Entry Add(Bird b)
    {
        var entry = new Entry();
        entry.bird = b;
        entries.Add(entry);

        flock.Add(b.GetComponent<Starling>());

        return entry;
    }
예제 #12
0
	void Awake(){
		if(instance == null){
			instance = this;
		}
		isAlive = true;
		flapButton = GameObject.FindGameObjectWithTag ("FlapButton").GetComponent<Button> ();
		flapButton.onClick.AddListener (() => FlapTheBird ());
		SetCameraX ();

		score = 0;
	}
예제 #13
0
        public string Go()
        {
            var dog = new Dog();
            var bird = new Bird();
            var fish = new Fish();

            var dogSays = dog.Speak();
            var birdSays = bird.Speak();
            var fishSays = fish.Speak();

            return dogSays + "\r\n" + birdSays + "\r\n" + fishSays + "\r\n";
        }
예제 #14
0
    public override void Enter(Bird owner)
    {
        birdsExploring++;

        standardColor = owner.standardColorIdle;

        moveSettings.cohesionMultiplier = -5.0f;

        //owner.StateGlobal.ChangeDirection();
        changeDirectionTimer = 0;
        cohesionToggleTimer = 0;
    }
예제 #15
0
파일: Program.cs 프로젝트: iProcyonidae/MVS
 static void Main(string[] args)
 {
     Console.WriteLine("Введи путь до input-файла: ");
     string input = Console.ReadLine(); //Входной файл.
     Console.WriteLine("Введи путь до output-файла: ");
     string output = Console.ReadLine(); //Выходной файл.
     string[] lines = File.ReadAllLines(input); //Считывание строк.
     int numOfFish = 0; //Количество рыб.
     int numOfBird = 0; //Количество птиц.
     for (int i = 0; i < lines.Length; i++)
     { //Считаем кол-во животных.
         if (lines[i].Length == 1 && i % 2 == 0 && Char.IsDigit(lines[i], 0) == true && lines[i][0] == '1')
             numOfFish++;
         if (lines[i].Length == 1 && i % 2 == 0 && Char.IsDigit(lines[i], 0) == true && lines[i][0] == '2')
             numOfBird++;
     }
     Fish[] fish = new Fish[numOfFish];
     Bird[] bird = new Bird[numOfBird];
     int fishIndex = 0; //Индекс рыб.
     int birdIndex = 0; //Индекс птиц.
     for (int i = 0; i < lines.Length; i++)
     {
         if (lines[i].Length == 1 && i % 2 == 0 && lines[i][0] == '1')
         {
             //Obj[j, 0] = int.Parse(lines[i]); //Получаем тип животного.
             string[] split = lines[i + 1].Split(new Char[] { ' ', '\n' }); //Получаем имя и характеристики.
             string Name = split[0]; //Записываем имя
             int charact = int.Parse(split[1]); //и характеристику.
             fish[fishIndex] = new Fish(Name, charact);
             fishIndex++;
         }
         if (lines[i].Length == 1 && i % 2 == 0 && lines[i][0] == '2')
         {
             //Obj[j, 0] = int.Parse(lines[i]); //Получаем тип животного.
             string[] split = lines[i + 1].Split(new Char[] { ' ', '\n' }); //Получаем имя и характеристики.
             string Name = split[0]; //Записываем имя
             int charact = int.Parse(split[1]); //и характеристику.
             bird[birdIndex] = new Bird(Name, charact);
             birdIndex++;
         }
     }
     lines = null;
     string text = "\nПтицы:\n"; //Строка которая запишется в файл.
     for (int i = 0; i < numOfBird; i++)
         text += bird[i].print();
     text += "\nРыбы:\n";
     for (int i = 0; i < numOfFish; i++)
         text += fish[i].print();
     Console.WriteLine(text); //Выводим результат в консоль
     File.WriteAllText(output, text, System.Text.Encoding.UTF8); //и записываем его в файл.
     Console.ReadKey(); //Тормозим консольку.
 }
예제 #16
0
    public StarlingWander(Bird bird, string[] _enemyTags, Bounds bbox)
        : base(bird)
    {
        var blended = new BlendedSteering[2];
        blended[0] = new BlendedSteering(bird, new BehaviorAndWeight(new ObstacleAvoidance (bird, LOOKAHEAD_DISTANCE, new string[]{"Ground"}), 1f));
        blended[1] = new BlendedSteering(bird, new BehaviorAndWeight(new SteeringBehaviors.Wander(bird, bird.maxSpeed, 5f, 5f, bbox), 1f));

        behavior = new PrioritySteering(1f, blended);

        enemyTags = _enemyTags;

        t = UnityEngine.Random.Range(MIN_TIME_CHANGE_DIRECTION, MAX_TIME_CHANGE_DIRECTION);
    }
예제 #17
0
    public override void Enter(Bird owner)
    {
        birdsFeeding++;

        standardColor = owner.standardColorFeeding;

        if (owner.Information.Count > 0)
        {
            // choose food source and copy its information (could be deleted because of age)
            owner.targetPoint = ChooseFoodSource(owner);
        }

        feedStateTimer = 0;
    }
        static void Main(string[] args)
        {
            var mimi = new Cat();
            mimi.Owner = "Pehso";
            mimi.Name = "Mimi";

            var stamat = new Dog("Stamat", "Minka");
            stamat.Bark();

            Lion koss = new Lion("Koss", 2, 300);
            koss.Roar();

            Bird sparrow = new Bird();
            sparrow.Sing();
        }
예제 #19
0
	public void ThrowBird(Bird currentBird, Pig targetPig, Vector2 slingPos)
	{
		if(_lastTargetPig)
			_lastTargetPig.GetComponent<SpriteRenderer>().material.color = Color.white;

		IsThrowingBird = true;
		
		_throwTimer = 0f;
		_currentBird = currentBird;

		// Highlight the target
		if(!GameWorld.Instance._isSimulation)
			targetPig.GetComponent<SpriteRenderer>().material.color = Color.red;

		_nextShot = Solve(currentBird, targetPig, slingPos);
		currentBird.SelectBird();
	}
예제 #20
0
파일: Game.cs 프로젝트: piwi93/Flappo-Bord
    // Update is called once per frame
    void Update()
    {
        if ((Input.GetKeyDown (KeyCode.Space) || Input.GetMouseButtonDown (0)) && gameStart == false) {
            gameStart = true;
            bird.GetComponent<Bird>().enabled = true;
            respawn.GetComponent<Respawn>().enabled = true;
            ground.GetComponent<Scroll>().enabled = true;

            birdScript = GameObject.Find("Bird").GetComponent<Bird>();
            birdScript.flap = true;
        }

        if(Time.time > timeaux && gameStart == false){
            timeaux = Time.time + 5;
            Instantiate(jumpSign, jumpSignPosition, transform.rotation);
        }
    }
예제 #21
0
    public override void Update(float dt, Bird bird)
    {
        var prioritySteering = (PrioritySteering)behavior;
        var avoidance = prioritySteering.Groups[0].Behaviors[0].behaviour as ObstacleAvoidance;
        var wander = prioritySteering.Groups[1].Behaviors[0].behaviour as Wander;

        UpdateSteering(dt);

        // make wander behavior's angle same as the target position of the avoidance behavior,
        // so that when wander will be used it will have the correct (current) angle of the bird
        // and not its old one
        if (prioritySteering.lastUsedSteering == 0) // obstacle avoidance
        {
            wander.LookAt(avoidance.targetPosition);
            wander.customYSpeed = 0f;
        }
    }
예제 #22
0
파일: Umbrella.cs 프로젝트: agaubatz/ggj16
	public void CollideWithBird(Bird b) {
		if (b.isGood) {
			state = UmbrellaState.Large;
			powerUpDuration = 4f;
			subs.SetActive(true);
		} else {
			AudioSource.PlayClipAtPoint (OwSound, transform.localPosition);
			powerUpDuration = 2f;
			state = UmbrellaState.Disabled;

			foreach (GameObject go in hurtObjects)
			{
				go.SetActive(true);
			}
			foreach (GameObject go in nonHurtObjects)
			{
				go.SetActive(false);
			}
		}
	}
예제 #23
0
    public override void Execute(Bird owner)
    {
        cohesionToggleTimer += Time.deltaTime;
        if (cohesionToggleTimer > Bird.settings.explore_changeCohesionAfter)
        {
            moveSettings.cohesionMultiplier = moveSettings.cohesionMultiplier == 2.0f ? -5.0f : 2.0f;
            cohesionToggleTimer = 0;
        }

        // state change
        if (owner.Hungry && owner.Information.Count > 0)
        {
            owner.ChangeState(owner.StateFeed);
        }

        changeDirectionTimer += Time.deltaTime;
        if (changeDirectionTimer >= Bird.settings.explore_changeDirectionAfter)
        {
            owner.StateGlobal.ChangeDirection();
            changeDirectionTimer = 0;
        }
    }
예제 #24
0
파일: Flock.cs 프로젝트: NStockwell/Boids
    /*
    public  ArrayList<ArrayList> getNeighbours(Bird bird)
    {
        Vector3 birdPosition = bird.transform.position;
        float birdSquareRadius = bird.getRadius();
        birdSquareRadius *= birdSquareRadius;
        float birdDirection = bird.getDirection();
        float birdAngleOfPerception = bird.getAngle();
        ArrayList birdsInNeighbourhood = new ArrayList<ArrayList>();
        birdsInNeighbourhood.Add(getNeighbours(bird, bird.getSeparationRange()));

        birdsInNeighbourhood.Add(getNeighbours(bird, bird.getAlignementRange()));

        birdsInNeighbourhood.Add(getNeighbours(bird, bird.getCohesionRange()));

        return birdsInNeighbourhood;
    }
    */
    public List<Bird> getNeighbours(Bird bird, float distance)
    {
        Vector3 birdPosition = bird.transform.position;
        float birdSquareRadius = distance;
        birdSquareRadius *= birdSquareRadius;
        float birdDirection = bird.transform.eulerAngles.z;//bird.getDirection();
        float birdAngleOfPerception = bird.getAngle();
        List<Bird> birdsInNeighbourhood = new List<Bird>();
        foreach (Bird b in _birds)
        {
            if(bird.getID() == b.getID())
                continue;

            Vector3 bPosition = b.transform.position;

            float diffX = bPosition.x - birdPosition.x;
            float diffY = bPosition.y - birdPosition.y;
            //check in range

            if(diffX*diffX + diffY*diffY <= birdSquareRadius)
            {

                //check if in correct angle interval
                //float arcTanInDegrees = Mathf.Atan2(diffY , diffX )  * 180 / Mathf.PI;

            //Debug.Log(diffX + " " + diffY + " " + birdSquareRadius + " " + arcTanInDegrees);
                //if( Utils.angle_between(	(int)arcTanInDegrees,
                //					(int)(birdDirection + birdAngleOfPerception/2),
                //					(int)(birdDirection - birdAngleOfPerception/2) ) )
                {
                    //Debug.Log("im in");
                    birdsInNeighbourhood.Add(b);
                }
            }
        }

        return birdsInNeighbourhood;
    }
예제 #25
0
    public static void UpdateSteering(Steering behavior, Bird bird, float dt)
    {
        if (behavior == null)
            return;

        var steering = behavior.GetSteering();

        if (!steering.IsNoSteering())
        {
            // update position
            bird.velocity += steering.linearVel * dt;

            bird.velocity = Vector3.ClampMagnitude(bird.velocity, bird.maxSpeed);

            if (bird.maxSpeed != 0f)
            {
                var rotation = Quaternion.LookRotation(bird.velocity);
                bird.transform.rotation = Quaternion.Slerp(bird.transform.rotation, rotation, 1f);
            }
        }
        else
            bird.GetComponent<Rigidbody>().velocity = Vector3.zero;
    }
예제 #26
0
 protected State(Bird bird, StateMachine stateMachine)
 {
     this.bird         = bird;
     this.stateMachine = stateMachine;
 }
 public void AddBird(Bird newBird)
 {
     Awake();
     birdList.Add(newBird);
 }
예제 #28
0
 public void InstantiateBird(Bird bird)
 {
     _bird = bird;
     _bird.MoveTo(gameObject.transform.position, gameObject);
     Collider.enabled = true;
 }
예제 #29
0
 public SingleBirdState(Bird _bird)
 {
     bird = _bird;
 }
예제 #30
0
 // Start is called before the first frame update
 void Start()
 {
     bird         = GameObject.FindObjectOfType <Bird>();
     queueColumns = new Queue <GameObject>();
     InitializeColumns();
 }
예제 #31
0
 public override void InitializeAgent()
 {
     birdScript    = GetComponent <Bird>();
     anim          = GetComponent <Animator>();
     startposition = new Vector2(0, 2.33f);
 }
예제 #32
0
파일: Animals.cs 프로젝트: Fynjyfun/Mono
    static void Main()
    {
        Animal[] animals = new Animal[4];

        Animal animal = new Animal();
        Bird   bird   = new Bird();

        bird.name = "Vasia";
        Cat  cat  = new Cat();
        Lion lion = new Lion();

        animals [0] = animal;
        animals [1] = bird;
        animals [2] = cat;
        animals [3] = lion;

        animal.Eat();
        bird.Eat();
        cat.Eat();
        lion.Eat();

        //animal.cells = 0;

        Console.WriteLine();

        int i;

        for (i = 0; i < 4; i++)
        {
            animals[i].Eat();
        }

        Console.WriteLine();

        ((Cat)animals[2]).Eat();

        Console.WriteLine();

        IFlying[] flying = new IFlying[2];

        Bat bat = new Bat();

        flying [0] = bat;
        flying [1] = bird;

        for (i = 0; i < 2; i++)
        {
            flying [i].Fly();
        }

        Console.WriteLine();

        Man    man    = new Man();
        Batman batman = new Batman();

        man.Eat();
        batman.Eat();
        batman.Fly();

        Console.WriteLine();

        Console.WriteLine(Animal.Quantity);
    }
예제 #33
0
 static void WorkWithBird(Bird bird)
 {
 }
예제 #34
0
    public void RunMain(ref Snake snake, ref Bird firebire, ref Venom venom, ref Fire fire, ref Image venomimg, ref Image fireimg)
    {
        switch (currentState)
        {
        case attackState.attackState_bird:
        {
            currentTime += Time.deltaTime;
            if (currentTime <= 3.0f)
            {
                fire.image.color  = new Color(1, 1, 1, 1.0f);                                              //火出现
                venom.image.color = new Color(1, 1, 1, 0.0f);                                              //毒液开始不存在
                harmsnake.color   = new Color(1, 1, 1, 0.0f);                                              //开始蛇没有受伤,所以不显示
                fire.image.rectTransform.position -= new Vector3(Time.deltaTime * fire.speed, 0.0f, 0.0f); //火移动
            }
            if (currentTime > 3.0f)
            {
                fire.image.color = new Color(1, 1, 1, 0.0f); //火消失
                if (Random.Range(0, 100) <= 30)              //机率为30%
                {
                    snake.blood     = snake.blood - firebird.burst;
                    harmsnake.text  = "-" + firebird.burst;
                    harmsnake.color = new Color(1, 1, 1, 1.0f);
                }
                else
                {
                    snake.blood     = snake.blood - firebird.attack;
                    harmsnake.text  = "-" + firebird.attack;
                    harmsnake.color = new Color(1, 1, 1, 1.0f);
                }
                numText1.text = snake.blood.ToString();
                currentState  = attackState.attackState_snake;
                currentTime   = 0.0f;
                fire.image.rectTransform.localPosition = new Vector3(128.0f, 33.0f, 0.0f);       //火回到原来的地方
                Debug.Log("换蛇进行攻击" + snake.blood);
            }
        }
        break;

        case attackState.attackState_snake:
        {
            currentTime += Time.deltaTime;
            if (currentTime <= 3.0f)
            {
                venom.image.color = new Color(1, 1, 1, 1.0f);                                                //毒液出现
                venom.image.rectTransform.position += new Vector3(Time.deltaTime * venom.speed, 0.0f, 0.0f); //毒液移动
                harmbird.color = new Color(1, 1, 1, 0.0f);                                                   //开始鸟没有受伤,所以不显示
            }
            if (currentTime > 3.0f)
            {
                venom.image.color = new Color(1, 1, 1, 0.0f); //毒液消失
                if (Random.Range(0, 100) <= 50)               //机率为50%
                {
                    firebird.blood = firebird.blood - snake.burst;
                    harmbird.text  = "-" + snake.burst;
                    harmbird.color = new Color(1, 1, 1, 1.0f);
                }
                else
                {
                    firebird.blood = firebird.blood - snake.attack;
                    harmbird.text  = "-" + snake.attack;
                    harmbird.color = new Color(1, 1, 1, 1.0f);
                }
                numText2.text = firebird.blood.ToString();
                currentState  = attackState.attackState_bird;
                currentTime   = 0.0f;
                venom.image.rectTransform.localPosition = new Vector3(29.0f, -12.0f, 0.0f);         //毒液回到原来的地方
                Debug.Log("换火鸟进行攻击" + firebird.blood);
            }
        }
        break;
        }
    }
예제 #35
0
 static void PrintNameAndWeight(Bird bird)
 {
     Console.WriteLine($"Name = {bird.Name}, Weight = {bird.Weight}");
 }
예제 #36
0
 private void Start()
 {
     Bird.GetInstance().OnDied += Bird_OnDied;
     Hide();
 }
예제 #37
0
 public void AssignTrail(Bird bird)
 {
     trailController.SetBird(bird);
     StartCoroutine(trailController.SpawnTrail());
     tapCollider.enabled = true;
 }
예제 #38
0
 static void Describe(Bird obj)
 {
     obj.Talk();
     obj.Fly();
 }
예제 #39
0
 public FlyableMethodsTests()
 {
     _bird  = new Bird(_coordinate, BirdSpecies.Raven, false, _speed);
     _plane = new Plane(_coordinate, PlaneManufacturers.Boeing, 13000.5, 900.8, 205.6, 4, 19.35);
     _drone = new Drone(_coordinate, 1000, 8000, 1200, 80);
 }
예제 #40
0
 void Awake()
 {
     bird = GameObject.FindObjectOfType <Bird>();
 }
예제 #41
0
 /**
  * Method to start the level.
  **/
 private void Start()
 {
     Bird.GetInstance().OnDied           += Bird_OnDied;
     Bird.GetInstance().OnStartedPlaying += Bird_OnStartedPlaying;
 }
예제 #42
0
        public void CollectionNamesTest()
        {
            var a  = new MongoRepository <Animal>();
            var am = new MongoRepositoryManager <Animal>();
            var va = new Dog();

            Assert.IsFalse(am.Exists);
            a.Update(va);
            Assert.IsTrue(am.Exists);
            Assert.IsInstanceOfType(a.GetById(va.Id), typeof(Dog));
            Assert.AreEqual(am.Name, "AnimalsTest");
            Assert.AreEqual(a.CollectionName, "AnimalsTest");

            var cl  = new MongoRepository <CatLike>();
            var clm = new MongoRepositoryManager <CatLike>();
            var vcl = new Lion();

            Assert.IsFalse(clm.Exists);
            cl.Update(vcl);
            Assert.IsTrue(clm.Exists);
            Assert.IsInstanceOfType(cl.GetById(vcl.Id), typeof(Lion));
            Assert.AreEqual(clm.Name, "Catlikes");
            Assert.AreEqual(cl.CollectionName, "Catlikes");

            var b  = new MongoRepository <Bird>();
            var bm = new MongoRepositoryManager <Bird>();
            var vb = new Bird();

            Assert.IsFalse(bm.Exists);
            b.Update(vb);
            Assert.IsTrue(bm.Exists);
            Assert.IsInstanceOfType(b.GetById(vb.Id), typeof(Bird));
            Assert.AreEqual(bm.Name, "Birds");
            Assert.AreEqual(b.CollectionName, "Birds");

            var l  = new MongoRepository <Lion>();
            var lm = new MongoRepositoryManager <Lion>();
            var vl = new Lion();

            //Assert.IsFalse(lm.Exists);   //Should already exist (created by cl)
            l.Update(vl);
            Assert.IsTrue(lm.Exists);
            Assert.IsInstanceOfType(l.GetById(vl.Id), typeof(Lion));
            Assert.AreEqual(lm.Name, "Catlikes");
            Assert.AreEqual(l.CollectionName, "Catlikes");

            var d  = new MongoRepository <Dog>();
            var dm = new MongoRepositoryManager <Dog>();
            var vd = new Dog();

            //Assert.IsFalse(dm.Exists);
            d.Update(vd);
            Assert.IsTrue(dm.Exists);
            Assert.IsInstanceOfType(d.GetById(vd.Id), typeof(Dog));
            Assert.AreEqual(dm.Name, "AnimalsTest");
            Assert.AreEqual(d.CollectionName, "AnimalsTest");

            var m  = new MongoRepository <Bird>();
            var mm = new MongoRepositoryManager <Bird>();
            var vm = new Macaw();

            //Assert.IsFalse(mm.Exists);
            m.Update(vm);
            Assert.IsTrue(mm.Exists);
            Assert.IsInstanceOfType(m.GetById(vm.Id), typeof(Macaw));
            Assert.AreEqual(mm.Name, "Birds");
            Assert.AreEqual(m.CollectionName, "Birds");

            var w  = new MongoRepository <Whale>();
            var wm = new MongoRepositoryManager <Whale>();
            var vw = new Whale();

            Assert.IsFalse(wm.Exists);
            w.Update(vw);
            Assert.IsTrue(wm.Exists);
            Assert.IsInstanceOfType(w.GetById(vw.Id), typeof(Whale));
            Assert.AreEqual(wm.Name, "Whale");
            Assert.AreEqual(w.CollectionName, "Whale");
        }
예제 #43
0
 // Use this for initialization
 void Awake()
 {
     this._direction = new Vector3();
     this._bird      = this.gameObject.GetComponent <Bird>();
 }
예제 #44
0
 // Use this for initialization
 void Start()
 {
     bird = FindObjectOfType <Bird>();
 }
 public void InitiateBird(Bird newBird)
 {
     bird = newBird;
     bird.MoveTo(gameObject.transform.position, gameObject);
     col.enabled = true;
 }
예제 #46
0
 public static void Start()
 {
     //ResetHighScore();
     Bird.GetInstance().OnDied += Bird_OnDied;
 }
        public void CollectionNamesTest()
        {
            var a = new MongoRepository<Animal>();
            var am = new MongoRepositoryManager<Animal>();
            var va = new Dog();
            Assert.IsFalse(am.Exists);
            a.Update(va);
            Assert.IsTrue(am.Exists);
            Assert.IsInstanceOfType(a.GetById(va.Id), typeof(Dog));
            Assert.AreEqual(am.Name, "AnimalsTest");
            Assert.AreEqual(a.CollectionName, "AnimalsTest");

            var cl = new MongoRepository<CatLike>();
            var clm = new MongoRepositoryManager<CatLike>();
            var vcl = new Lion();
            Assert.IsFalse(clm.Exists);
            cl.Update(vcl);
            Assert.IsTrue(clm.Exists);
            Assert.IsInstanceOfType(cl.GetById(vcl.Id), typeof(Lion));
            Assert.AreEqual(clm.Name, "Catlikes");
            Assert.AreEqual(cl.CollectionName, "Catlikes");

            var b = new MongoRepository<Bird>();
            var bm = new MongoRepositoryManager<Bird>();
            var vb = new Bird();
            Assert.IsFalse(bm.Exists);
            b.Update(vb);
            Assert.IsTrue(bm.Exists);
            Assert.IsInstanceOfType(b.GetById(vb.Id), typeof(Bird));
            Assert.AreEqual(bm.Name, "Birds");
            Assert.AreEqual(b.CollectionName, "Birds");

            var l = new MongoRepository<Lion>();
            var lm = new MongoRepositoryManager<Lion>();
            var vl = new Lion();
            //Assert.IsFalse(lm.Exists);   //Should already exist (created by cl)
            l.Update(vl);
            Assert.IsTrue(lm.Exists);
            Assert.IsInstanceOfType(l.GetById(vl.Id), typeof(Lion));
            Assert.AreEqual(lm.Name, "Catlikes");
            Assert.AreEqual(l.CollectionName, "Catlikes");

            var d = new MongoRepository<Dog>();
            var dm = new MongoRepositoryManager<Dog>();
            var vd = new Dog();
            //Assert.IsFalse(dm.Exists);
            d.Update(vd);
            Assert.IsTrue(dm.Exists);
            Assert.IsInstanceOfType(d.GetById(vd.Id), typeof(Dog));
            Assert.AreEqual(dm.Name, "AnimalsTest");
            Assert.AreEqual(d.CollectionName, "AnimalsTest");

            var m = new MongoRepository<Bird>();
            var mm = new MongoRepositoryManager<Bird>();
            var vm = new Macaw();
            //Assert.IsFalse(mm.Exists);
            m.Update(vm);
            Assert.IsTrue(mm.Exists);
            Assert.IsInstanceOfType(m.GetById(vm.Id), typeof(Macaw));
            Assert.AreEqual(mm.Name, "Birds");
            Assert.AreEqual(m.CollectionName, "Birds");

            var w = new MongoRepository<Whale>();
            var wm = new MongoRepositoryManager<Whale>();
            var vw = new Whale();
            Assert.IsFalse(wm.Exists);
            w.Update(vw);
            Assert.IsTrue(wm.Exists);
            Assert.IsInstanceOfType(w.GetById(vw.Id), typeof(Whale));
            Assert.AreEqual(wm.Name, "Whale");
            Assert.AreEqual(w.CollectionName, "Whale");
        }
예제 #48
0
 public abstract void Update(float dt, Bird bird);
예제 #49
0
 void Start()
 {
     bird = GameObject.Find("Bird").GetComponent <Bird>();
     bird.setValue(2f);
     bird.MoveDynamicStructure();
 }
예제 #50
0
 public BirdImage(Bird bird)
 {
     Bird = bird;
 }
예제 #51
0
 private void Start()
 {
     //CreatePipe(40f, 20f, true);
     Bird.GetInstance().OnDied           += Bird_OnDied;
     Bird.GetInstance().OnStartedPlaying += Bird_OnStartedPlaying;
 }
예제 #52
0
 protected void Awake()
 {
     owner = transform.parent.gameObject.GetComponent<Bird>();
     Physics.IgnoreCollision(collider, GameObject.Find(GlobalNames.Names.Environment).collider);
 }
예제 #53
0
        static void Main(string[] args)
        {
            List <Accessory> accessories = new List <Accessory>();
            List <Animal>    animals     = new List <Animal>();

            var leatherGloves = new Gloves();

            leatherGloves.Name  = "Leather Gloves";
            leatherGloves.Color = "Brown";
            leatherGloves.Cost  = 135;
            accessories.Add(leatherGloves);

            var tophat = new Hat();

            tophat.Name  = "a Tophat";
            tophat.Color = "Black";
            tophat.Cost  = 255;
            accessories.Add(tophat);

            var rolex = new Watch();

            rolex.Name  = "a Rolex Watch";
            rolex.Color = "Gold";
            rolex.Cost  = 433000;
            accessories.Add(rolex);

            var polly = new Bird();

            polly.Name          = "Polly";
            polly.Color         = "Green";
            polly.NumberOfLimbs = 4;
            animals.Add(polly);

            var snowball = new Cat();

            snowball.Name          = "Snowball";
            snowball.Color         = "White";
            snowball.NumberOfLimbs = 4;
            animals.Add(snowball);

            var nemo = new Fish();

            nemo.Name          = "Nemo";
            nemo.Color         = "Orange";
            nemo.NumberOfLimbs = 0;
            animals.Add(nemo);

            foreach (var accesory in accessories)
            {
                Console.WriteLine();
                Console.WriteLine("This accesory is " + accesory.Name);
                Console.WriteLine("This accessory is the color " + accesory.Color);
                Console.WriteLine("This accessory costs " + accesory.Cost + " SEK");

                if (accesory is Gloves gloves)
                {
                    gloves.Usage();
                    gloves.Reaction();
                }

                else if (accesory is Hat hat)
                {
                    hat.Usage();
                    hat.Reaction();
                }

                else if (accesory is Watch watch)
                {
                    watch.Usage();
                    watch.Reaction();
                }
            }

            foreach (var animal in animals)
            {
                Console.WriteLine();
                Console.WriteLine("This animal's name is " + animal.Name);
                Console.WriteLine("This animal is the color " + animal.Color);
                Console.WriteLine("This animal has " + animal.NumberOfLimbs + " number of limbs");

                if (animal is Bird bird)
                {
                    bird.Move();
                    bird.Eat();
                }

                else if (animal is Cat cat)
                {
                    cat.Move();
                    cat.Eat();
                }

                else if (animal is Fish fish)
                {
                    fish.Move();
                    fish.Eat();
                }
            }
        }
예제 #54
0
 public override void Update(float dt, Bird bird)
 {
 }
예제 #55
0
        // CONSTRUCTOR
        public MenuGame()
            : base()
        {
            switch (Settings.gameMode)
            {
            case GameMODE.SKY:
                this.background = new Sprite("background_sky", 0, 0);
                this.ground     = new Ground(0, 1100, new Sprite("ground_sky"));
                this.player     = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO),
                                           new AnimatedSprite("bird", 125, 70, 1, SheetOrientation.HORIZONTAL, 20, 20));
                break;

            case GameMODE.SEA:
                this.background = new Sprite("background_sea", 0, 0);
                this.ground     = new Ground(0, 1100, new Sprite("ground_sea"));
                this.player     = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO),
                                           new AnimatedSprite("submarine", 125, 90, 1, SheetOrientation.HORIZONTAL, 20, 20));
                break;

            case GameMODE.JUNGLE:
                this.background = new Sprite("background_jungle", 0, 0);
                this.ground     = new Ground(0, 1100, new Sprite("ground_jungle"));
                this.player     = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO),
                                           new AnimatedSprite("bug", 125, 100, 1, SheetOrientation.HORIZONTAL, 20, 20));
                break;

            case GameMODE.SPACE:
                this.background = new Sprite("background_space", 0, 0);
                this.ground     = new Ground(0, 1100, new Sprite("ground_space"));
                this.player     = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO),
                                           new AnimatedSprite("alien", 125, 73, 1, SheetOrientation.HORIZONTAL, 20, 20));
                break;

            default:
                this.background = new Sprite("background_sky", 0, 0);
                this.ground     = new Ground(0, 1100, new Sprite("ground_sky"));
                this.player     = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO),
                                           new AnimatedSprite("bird", 125, 70, 1, SheetOrientation.HORIZONTAL, 20, 20));
                break;
            }

            this.getReady    = new Sprite("getready", (int)(80 * (int)Settings.PIXEL_RATIO), 230);
            this.pipes       = new List <Pipe>();
            this.start       = false;
            this.gameover    = false;
            this.setRotation = false;
            this.timer       = 0;
            this.random      = new Random();
            this.gameOver    = new Sprite("gameover", (int)(80 * (int)Settings.PIXEL_RATIO), 230);

            scoreBoxX       = 50 * (int)Settings.PIXEL_RATIO;
            scoreBoxY       = 400;
            this.scoreBox   = new Sprite("score_box", scoreBoxX, scoreBoxY);
            this.baseScoreX = scoreBoxX;
            this.baseScoreY = scoreBoxY;

            this.retryButton = new MyButton(scoreBoxX + 100, scoreBoxY + 350,
                                            new AnimatedSprite("game_buttons", 120, 120, 1, SheetOrientation.HORIZONTAL, 0, 0));
            this.menuButton = new MyButton(scoreBoxX + 350, scoreBoxY + 350,
                                           new AnimatedSprite("game_buttons", 120, 120, 2, SheetOrientation.HORIZONTAL, 0, 0));

            this.score        = 0;
            this.highscore    = 0;
            this.newHighscore = false;
            this.medal        = new AnimatedSprite("medals", 135, 156, 0, SheetOrientation.HORIZONTAL, scoreBoxX + 62, scoreBoxY + 105);
            this.newScore     = new Sprite("new", scoreBoxX + 230, scoreBoxY + 180);
        }