コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("PlayerTestSpawnPoint activating");
        //Set player position
        PlayerController pc = FindObjectOfType <PlayerController>();

        pc.transform.position = transform.position;
        //Activate abilities
        checkAbility(ForceLaunchAbility, pc.GetComponent <ForceLaunchAbility>());
        checkAbility(SwapAbility, pc.GetComponent <SwapAbility>());
        checkAbility(WallClimbAbility, pc.GetComponent <WallClimbAbility>());
        checkAbility(AirSliceAbility, pc.GetComponent <AirSliceAbility>());
        checkAbility(ElectricBeamAbility, pc.GetComponent <ElectricBeamAbility>());
        checkAbility(LongTeleportAbility, pc.GetComponent <LongTeleportAbility>());

        //Destroy object
        //If it's under a ruler displayer,
        RulerDisplayer rd = GetComponentInParent <RulerDisplayer>();

        if (rd)
        {
            //Destroy that ruler displayer and everything under it
            Destroy(rd.gameObject);
        }
        else
        {
            //Otherwise just destroy this spawn point object
            Destroy(gameObject);
        }
    }
コード例 #2
0
    public static void callMerky()
    {
        if (Application.isEditor && !Application.isPlaying)
        {
            PlayerTestSpawnPoint playerTSP         = GameObject.FindObjectOfType <PlayerTestSpawnPoint>();
            GameObject           playerSpawnObject = playerTSP.gameObject;

            //Enable it
            playerTSP.enabled = true;
            playerSpawnObject.SetActive(true);
            RulerDisplayer rd = GameObject.FindObjectOfType <RulerDisplayer>();
            if (rd)
            {
                rd.transform.position = RulerDisplayer.currentMousePos;
            }
            else
            {
                playerSpawnObject.transform.position = (Vector2)SceneView.GetAllSceneCameras()[0].transform.position;
            }
            Selection.activeGameObject = playerSpawnObject;
        }
        else
        {
            //Call the player
            GameObject playerObject = GameObject.FindObjectOfType <PlayerController>().gameObject;
            if (GameObject.FindObjectOfType <RulerDisplayer>())
            {
                playerObject.transform.position = RulerDisplayer.currentMousePos;
            }
            else
            {
                playerObject.transform.position = (Vector2)SceneView.GetAllSceneCameras()[0].transform.position;
            }
            Selection.activeGameObject = playerObject;
        }
    }