protected void Start()
 {
     PersonModel = GetComponent<BasePersonModel>();
     PersonPhysics = GetComponent<BasePhysics>();
     PersonAnimator = GetComponent<Animator>();
     PersonPhysics.SetVelocity(PersonModel.Velocity);
 }
    void Start()
    {
        anim = GetComponent<Animator>();
        physics = GetComponent<BasePhysics>();

        if (physics != null) animUpdate += Physics;

        if (animUpdate == null) this.enabled = false;
    }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     BasePhysics = GetComponent<BasePhysics>();
 }
 void Start()
 {
     _enemyPhysics = GetComponent<NewColliderLogicPhysics>();
 }
Exemple #5
0
 void Start()
 {
     _enemyPhysics = GetComponent<EnemyPhysics>();
 }
Exemple #6
0
    // Update is called once per frame
    // We cant use fixed update when dealing with inputs

    //TODO: we should first check input and then balls in the zones
    void Update()
    {
        // flag indicates that there are some balls in catcher zone
        if (balls_to_be_catched.Count > 0)
        {
            // trying to catch
            if (Input.GetMouseButton(0))
            {
                startPowerAccAndShowUI(0);

                // if ball catched
                if (locked_ball)
                {
                    // throttle
                    if (powerAcc0 > 30 && powerAcc0 % 10 == 0)
                    {
                        baseCtrl.ChangeCams(1);
                        if (!chrg_sound.isPlaying)
                        {
                            chrg_sound.Play();
                        }
                        aim_panel.SetActive(true);
                    }

                    // if ball is not catched
                }
                else
                {
                    // just take the first ball
                    Collider catched_ball = balls_to_be_catched[0];
                    catched_ball.GetComponent <SphereCollider>().isTrigger = true;
                    catched_ball.attachedRigidbody.isKinematic             = true;
                    catched_ball.attachedRigidbody.velocity = Vector3.zero;
                    // Probably dont' need, check
                    catched_ball.attachedRigidbody.angularVelocity = Vector3.zero;
                    catched_ball.transform.SetParent(this.transform);
                    catched_ball.gameObject.transform.localPosition = new Vector3(0, -0.2f, 0);
                    locked_ball = catched_ball;

                    Vector3 move_back = new Vector3(0, 0, -2f);
                    PlayerCtrl.transform.position += move_back;
                }
            }

            // releasing catch button
            if (Input.GetMouseButtonUp(0))
            {
                // and we actually have catched ball
                if (locked_ball)
                {
                    Vector3 mp = Input.mousePosition;
                    // reset to 0,0 center coordinates
                    mp.x -= Screen.width / 2;
                    mp.y -= Screen.height / 2;

                    BasePhysics.startSpinForCoordinates(mp);
                }
                else
                {
                    Debug.Log("what do we do here?");
                }

                // reset power and UI
                aim_panel.SetActive(false);
                chrg_sound.Stop();
                baseCtrl.ChangeCams(3);
                stopPowerAccAndHideUI(0);
            }

            // trying to shoot the ball
            if (Input.GetMouseButton(1))
            {
                startPowerAccAndShowUI(1);

                // throttle every 10 * 0.02 s
                if (powerAcc1 > 30 && powerAcc1 % 10 == 0)
                {
                    baseCtrl.ChangeCams(1);
                    if (!glu_sound.isPlaying)
                    {
                        glu_sound.Play();
                    }
                    aim_panel.SetActive(true);
                }

                float force = powerAcc1 / 5;
                Ray   ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
                // debug ray
                baseCtrl.drawProjectile(locked_ball.attachedRigidbody, ray.direction * force, locked_ball.attachedRigidbody.drag, 1f, Time.fixedDeltaTime);
            }

            // when shoot button is released
            if (Input.GetMouseButtonUp(1))
            {
                // if we have the ball in cather zone
                if (locked_ball)
                {
                    locked_ball.transform.SetParent(null);
                    locked_ball.GetComponent <SphereCollider>().isTrigger = false;
                    locked_ball.attachedRigidbody.isKinematic             = false;

                    // TODO: This ray comes fromom camera, wrong direction
                    Ray   ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
                    float force = powerAcc1 / 5;

                    //Trying to give force manually
                    //baseCtrl.locked_ball.attachedRigidbody.AddForce(ray.direction * force, ForceMode.Impulse);
                    //locked_ball.attachedRigidbody.velocity = ray.direction * force /  locked_ball.attachedRigidbody.mass;
                    BasePhysics.addVelocity(locked_ball.attachedRigidbody, ray.direction * force / locked_ball.attachedRigidbody.mass);

                    locked_ball = null;
                    start_spin  = false;

                    aim_panel.SetActive(false);
                    glu_sound.Stop();
                    baseCtrl.ChangeCams(3);

                    stopPowerAccAndHideUI(1);
                }
                else
                {
                    Debug.Log("Probably should not trigger");
                }
            }

            // indicates that there are balls in vacuum zone
        }
        else if (baseCtrl.in_vacuum_zone)
        {
            if (Input.GetMouseButton(0))
            {
                startPowerAccAndShowUI(0);
            }

            if (Input.GetMouseButtonUp(0))
            {
                foreach (Collider ball in baseCtrl.balls_in_vacuum_zone)
                {
                    float   force     = powerAcc0 / 5;
                    Vector3 direction = this.transform.position - ball.transform.position;
                    BasePhysics.addVelocity(ball.attachedRigidbody, direction * force / ball.attachedRigidbody.mass);
                }

                stopPowerAccAndHideUI(0);
            }
        }
        // indicates that there are no balls nearby
        else
        {
            if (Input.GetMouseButton(0))
            {
                startPowerAccAndShowUI(0);
            }

            if (Input.GetMouseButtonUp(0))
            {
                stopPowerAccAndHideUI(0);
            }
        }
    }