示例#1
0
    // Update is called once per frame
    void Update()
    {
        InputUpdates [PlayerInputState] ();
        if (Input.GetMouseButtonDown(0))
        {
            if (ActiveGrapplingHook != null)
            {
                GrapplingState = E_GrapplingState.Detached;
                if (PlayerInputState == E_PlayerInputState.Swinging)
                {
                    PlayerInputState = E_PlayerInputState.Free;
                }
                GameObject.Destroy(ActiveGrapplingHook);
            }
            Vector3 v3     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            float   vx     = v3.x - body.position.x;
            float   vy     = v3.y - body.position.y;
            double  vangle = Trig.GetAngle(new Vector2(vx, vy));
            ActiveGrapplingHook = Instantiate(GrapplingHookBase, new Vector3(body.position.x + Mathf.Cos((float)vangle), body.position.y + Mathf.Sin((float)vangle), 0), new Quaternion()).gameObject;
            ActiveGrapplingHook.GetComponent <GrapplingHookController> ().SetPendulum(this);
            ActiveGrapplingHook.SetActive(true);
            ActiveGrapplingHook.GetComponent <Rigidbody2D>().velocity = new Vector2(50 * Mathf.Cos((float)vangle), 50 * Mathf.Sin((float)vangle));
        }

        if ((Input.GetMouseButtonDown(1)) && (ActiveGrapplingHook != null))
        {
            GrapplingState = E_GrapplingState.Detached;
            GameObject.Destroy(ActiveGrapplingHook);
            ActiveGrapplingHook = null;
            if (PlayerInputState == E_PlayerInputState.Swinging)
            {
                PlayerInputState = E_PlayerInputState.Free;
            }
        }
    }
示例#2
0
 public void CreateAnchor()
 {
     GrapplingState = E_GrapplingState.Attached;
     if (PlayerInputState == E_PlayerInputState.Free)
     {
         PlayerInputState = E_PlayerInputState.Swinging;
     }
 }
示例#3
0
    // Use this for initialization
    void Start()
    {
        MainCameraController controller = Camera.main.GetComponent <MainCameraController> ();

        controller.SendMessage("PlayerSpawned", this.gameObject);

        body = GetComponent <Rigidbody2D> ();
        Manager.ObjectLog.Add(gameObject, this);
        GrapplingState = E_GrapplingState.Detached;
        InvokeRepeating("MapCheck", 0f, 0.5f);
    }