Beispiel #1
0
	// Use this for initialization
	void Start () {
        this.main_camera = GameObject.Find("Main Camera");

        // mobile
        this.left_button = GameObject.Find("Left Button").GetComponent<UIButtonInput>();
        this.right_button = GameObject.Find("Right Button").GetComponent<UIButtonInput>();
        this.jump_button = GameObject.Find("Jump Button").GetComponent<UIButtonInput>();
        this.action_button = GameObject.Find("Action Button").GetComponent<UIButtonInput>();
        // end mobile

        // pc
        /*this.left_button = new UIButtonInput();
        this.right_button = new UIButtonInput();
        this.jump_button = new UIButtonInput();
        this.action_button = new UIButtonInput();*/
        // end pc

        this.player = PlayerBehavior.CreatePlayerBehavior();
        this.carrying_carrot = null;
        this.carrots = new List<CarrotBehavior>();
        this.stems = new List<StemBehavior>();

        this.AddStem();
        this.AddStem();
    }
Beispiel #2
0
 protected static CarrotBehavior InitializeCarrotBehavior(CarrotBehavior behavior, float x, float y)
 {
     InitializeRigidbodyBehavior(behavior, ColliderType.Polygon, "carrot", x, y);
     behavior.touching_player = false;
     behavior.gameObject.transform.localScale = new Vector3(scale, scale);
     return behavior;
 }
Beispiel #3
0
    public void Action()
    {
        var touching_stem = this.FindStemTouchingPlayer();
        var touching_carrot = this.FindCarrotsTouchingPlayer();

        
        if (this.carrying_carrot == null)
        {
            // pick up
            if (touching_carrot != null)
            {
                // existing carrot
                this.carrying_carrot = touching_carrot;
                this.carrying_carrot.collider2d.enabled = false;
                this.carrots.Remove(carrying_carrot);
            }
            else if (touching_stem != null)
            {
                // stem
                this.carrying_carrot = CarrotBehavior.CreateCarrotBehavior();
                this.carrying_carrot.collider2d.enabled = false;
                this.stems.Remove(touching_stem);
                Destroy(touching_stem.gameObject);
                this.AddStem();
            }
        }
        else if (this.carrying_carrot != null)
        {
            // throw carrot
            this.carrying_carrot.gameObject.transform.position += new Vector3(0, 1);
            this.carrying_carrot.rigid_body.velocity = this.player.rigid_body.velocity + new Vector2(PlayerBehavior.horiz_throw * this.player.facing, PlayerBehavior.vert_throw);
            this.carrying_carrot.collider2d.enabled = true;
            this.carrying_carrot.touching_player = false;
            this.player.touching_anything = false;
            carrots.Add(this.carrying_carrot);
            this.carrying_carrot = null;
        }
    }