示例#1
0
    // Use this for initialization
    void Awake() {
        scr_ObjectFactory = GameObject.FindGameObjectWithTag("ObjectFactory").GetComponent<objectFactory>();

        scoreText = GameObject.FindGameObjectWithTag("scoreText").GetComponent<ScoreManager>();
        passedTop = false;
        rotation = new Vector3(0, 0, 0);
        blueClimbRotation = new Vector3(0, 0, 0);
        redClimbRotation = new Vector3(0, 0, 0);
        isGrounded = true;
        allowFalling = true;
        colTrggerCount = 0;
        redDirectionValue = runningSpeed;
        blueDirectionValue = -runningSpeed;
        running = new Vector3(runningSpeed,0.0f);
        runningSlope = new Vector3(slopeRunningSpeed, slopeRunningSpeed);
        climbing = new Vector3(0.0f, climbingSpeed);
        falling = new Vector3(0.0f, -climbingSpeed);
        currentState = manState.Running;
        //directionValue = 10.0f;

        //frontCollider = Instantiate(objectFactory.pdf_ManMiniCollider) as GameObject;
        //frontCollider.GetComponent<BoxCollider2D>().isTrigger = true;
        //frontCollider.GetComponent<scr_manMiniCollider>().Initialize(this.gameObject);
        groundCollider = Instantiate(scr_ObjectFactory.pdf_ManGroundCollider) as GameObject;
        groundCollider.GetComponent<scr_manGroundCollider>().Initialize(this.gameObject);


        backCollider = Instantiate(scr_ObjectFactory.pdf_ManMiniCollider) as GameObject;
        backCollider.GetComponent<scr_manMiniCollider>().Initialize(this.gameObject);


        manRenderer = GetComponent<Renderer>();
    }
示例#2
0
 void OnTriggerEnter2D(Collider2D otherObject)
 {
     if (otherObject.gameObject.name == "slope" || otherObject.gameObject.name == "slope 1")
     {
         // Debug.Log(otherObject.gameObject.GetComponent<EdgeCollider2D>().points[1] + " " + manColour);
         slopeObject = otherObject.gameObject.GetComponent<EdgeCollider2D>();
         currentState = manState.ColWithSlope;
     }
     if (otherObject.gameObject.tag == "ground")
     {
         scr_ground groundScript = otherObject.gameObject.GetComponent<scr_ground>();
         if (groundScript.currentState == scr_ground.groundState.Falling)
         {
             Destroy(gameObject);
         }
     }
 }
示例#3
0
 void OnCollisionEnter2D(Collision2D otherObject)
 {
     
     if (otherObject.gameObject.name == "RaiseZone")
     {
         GetComponent<Rigidbody2D>().isKinematic = true;
         currentState = manState.Raising;
     }
 }