示例#1
0
    private void CreateShooter(Army army)
    {
        GameObject           cameraObj  = GameObject.Find("MainCamera");
        MainCameraController controller = cameraObj.GetComponent <MainCameraController>();

        GameObject shooter = GameObject.Find("Shooter");

        Vector3    position = Vector3.zero;
        Quaternion rotation = Quaternion.identity;
        string     name     = "";

        if (army == Army.Army_Red)
        {
            position = controller.WorldSpaceToUnitSpace(new Vector3(0.0f, 7.0f, 0.0f));
            rotation = new Quaternion(0, 0, 0, 35);

            name = "red";
        }
        else if (army == Army.Army_Blue)
        {
            position = controller.WorldSpaceToUnitSpace(new Vector3(0.0f, -7.0f, 0.0f));
            rotation = new Quaternion(0, 0, 0, 155);

            name = "blue";
        }

        GameObject shooterObj = Instantiate(shooter, position, rotation);

        shooterObj.name = name;
        Shooter shooterScript = shooterObj.GetComponent <Shooter>();

        shooterScript.m_myArmy = army;
        shooterScript.PostStart();
    }