예제 #1
0
 // Use this for initialization
 void Awake()
 {
     myRBD2D    = GetComponentInChildren <Rigidbody2D> ();
     myPCD      = GetComponentInChildren <PlayerCollisionDetector> ();
     gManager   = FindObjectOfType <GameManager> ();
     SoundM     = FindObjectOfType <SoundManager> ();
     glowScales = new Vector3[glows.Length];
     for (int i = 0; i < glows.Length; i++)
     {
         glowScales [i] = new Vector3(glows [i].transform.localScale.x, glows [i].transform.localScale.y, glows [i].transform.localScale.z);
     }
     base.Awake();
     //Debug.Log ("Start called");
     gravity  = 1;
     oldscale = scaleMultiplier / rigidbody.position.y;
     if (keys == null)
     {
         IDictionary <string, KeyCode> defaultKeys = new Dictionary <string, KeyCode> ();
         defaultKeys.Add("left", KeyCode.A);
         defaultKeys.Add("right", KeyCode.D);
         defaultKeys.Add("gravityChange", KeyCode.S);
         defaultKeys.Add("shoot", KeyCode.W);
         //setKeys (defaultKeys);
     }
 }
예제 #2
0
    void IAmBumpKing(PlayerCollisionDetector HisPCD, Vector2 myVelocity, Collision2D coll)
    {
        HisPCD.BumpAway(myVelocity);
        SelfBump(myVelocity);
        Vector2 contactPoint = coll.contacts[0].point;

        MakeBumpEffect(contactPoint);
    }
예제 #3
0
    void Start()
    {
        anim = GetComponent <Animator> ();
        collisionDetector = GetComponent <PlayerCollisionDetector> ();

        // This considers that the lanes are equally far apart
        changeLaneTime = (lanes[1].position.x - lanes[0].position.x) / lateralSpeed;
    }
예제 #4
0
    // Use this for initialization
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "Player")
        {
            PlayerCollisionDetector HisPCD = coll.gameObject.GetComponent <PlayerCollisionDetector>();
            Vector2 myVelocity             = prevVelocity;
            if (HisPCD != null)
            {
                Vector2     hisVelocity = HisPCD.PrevVelocity;
                Rigidbody2D hisRbd      = coll.rigidbody;
                //Debug.Log("his velocity "+hisVelocity + " my velocity "+ myVelocity);
                if (myVelocity.magnitude >= hisVelocity.magnitude)
                {
                    //Debug.Log("My speed was: "+myVelocity.magnitude);

                    if (IsMaxSpeedKiller)
                    {
                        if (myVelocity.magnitude >= MaxPlayerSpeed)
                        {
                            if (hisVelocity.magnitude >= MaxPlayerSpeed)
                            {
                                MaxSpeedBump(HisPCD, myVelocity, coll);
                                Debug.Log("Max Speed Collision");
                            }
                            else
                            {
                                MakeBumpEffect(coll.contacts[0].point);
                                LocalPlayerController hisLCP = coll.gameObject.GetComponentInParent <LocalPlayerController>();
                                if (hisLCP.hasShield)
                                {
                                    hisLCP.DisableShield();
                                }
                                else
                                {
                                    hisLCP.DestroyObject();
                                }
                                Debug.Log("P1 At Max speed only");
                            }
                        }
                    }
                    else
                    {
                        IAmBumpKing(HisPCD, myVelocity, coll);
                    }
                    //hisRbd.ad
                }
            }
        }
    }
예제 #5
0
 protected override void Reset()
 {
     base.Reset();
     m_collisionDetector = GetComponent <PlayerCollisionDetector>();
 }