Inheritance: MonoBehaviour
コード例 #1
0
ファイル: HeroSwim.cs プロジェクト: uenie/first-gate
    void Start()
    {
        hero       = transform;
        rb         = GetComponent <Rigidbody>();
        liftVector = new Vector3(0, 2.0f, 0);
        hMove      = GetComponent <HeroMotor> () as HeroMotor;
        hPhys      = GetComponent <HeroPhysic> () as HeroPhysic;
        hCam       = GetComponent <HeroCamera> () as HeroCamera;
        hClimb     = GetComponent <HeroClimb> () as HeroClimb;
        if (hCam.cam)
        {
            cam = hCam.cam;
        }
        bones = GetComponentsInChildren <Transform> () as Transform[];
        foreach (Transform t in bones)
        {
            if (t.name == "root")
            {
                rootB = t;
            }
        }
        // FX
        GameObject gO = (GameObject)Resources.Load("FX_WaterSurf");

        surfSplash        = (GameObject)Instantiate(gO, hero.position, Quaternion.identity);
        surfSplash.active = false;
    }
コード例 #2
0
ファイル: HeroInit.cs プロジェクト: hardman/unitygame
    private void onEvent(string evt, object data)
    {
        switch (evt)
        {
            case Events.EVENT_INPUT_JUMP:
                mAnimCtl.startJump();
                break;
            case Events.EVENT_INPUT_SCREEN_CLICK:
                mAnimCtl.startRun((Vector3)data);
                break;
            case Events.EVENT_SELECT_HERO:
                string selectName = (string)data;
                Debug.Log("select hero selectName = " + selectName);
                this.getUtil().SelectedHeroName = selectName;
                if (selectName.Equals(this.gameObject.name))
                {
                    mapEvent(Events.EVENT_INPUT_JUMP, onEvent);
                    mapEvent(Events.EVENT_INPUT_SCREEN_CLICK, onEvent);

                    mCamera = this.gameObject.AddComponent<HeroCamera>();

                    //让gameObject检查同步
                    HeroSync.init();
                    GlobalObject.getComponent<HeroSync>().registerSync(gameObject.name, gameObject);
                }
                Debug.Log("before onEvent break");
                break;
            default:
                break;
        }
    }
コード例 #3
0
ファイル: HeroInit.cs プロジェクト: asdlei99/unitygame
    private void onEvent(string evt, object data)
    {
        switch (evt)
        {
        case Events.EVENT_INPUT_JUMP:
            mAnimCtl.startJump();
            break;

        case Events.EVENT_INPUT_SCREEN_CLICK:
            mAnimCtl.startRun((Vector3)data);
            break;

        case Events.EVENT_SELECT_HERO:
            string selectName = (string)data;
            Debug.Log("select hero selectName = " + selectName);
            this.getUtil().SelectedHeroName = selectName;
            if (selectName.Equals(this.gameObject.name))
            {
                mapEvent(Events.EVENT_INPUT_JUMP, onEvent);
                mapEvent(Events.EVENT_INPUT_SCREEN_CLICK, onEvent);

                mCamera = this.gameObject.AddComponent <HeroCamera>();

                //让gameObject检查同步
                HeroSync.init();
                GlobalObject.getComponent <HeroSync>().registerSync(gameObject.name, gameObject);
            }
            Debug.Log("before onEvent break");
            break;

        default:
            break;
        }
    }
コード例 #4
0
ファイル: HeroMovement.cs プロジェクト: ajmed/blink
    void Start()
    {
        resetMovement();

        heroAvatar          = GetComponent <HeroAvatar> ();
        characterController = GetComponent <CharacterController>();
        camera      = GetComponentInChildren <Camera>(true);
        heroCamera  = GetComponent <HeroCamera> ();
        heroManager = GetComponent <HeroManager> ();

        heroActionMap = new Dictionary <MovementAction, VoidFunc> {
            { MovementAction.MinusX, MinusX },
            { MovementAction.MinusY, MinusY },
            { MovementAction.MinusZ, MinusZ },
            { MovementAction.PlusX, PlusX },
            { MovementAction.PlusY, PlusY },
            { MovementAction.PlusZ, PlusZ },
            { MovementAction.MinusYRotate, MinusYRotate },
            { MovementAction.PlusYRotate, PlusYRotate },
            { MovementAction.ChangeCameraAngle, ChangeCameraAngle },
            { MovementAction.ChangeHeroAngle, ChangeHeroAngle },
            { MovementAction.ToggleRunWalk, ToggleRunWalk }
        };
    }
コード例 #5
0
ファイル: HeroSwim.cs プロジェクト: Hotblack/project-other
 void Start()
 {
     hero = transform;
     rb = rigidbody;
     liftVector = new Vector3 (0, 2.0f, 0);
     hMove = GetComponent <HeroMotor> () as HeroMotor;
     hPhys = GetComponent <HeroPhysic> () as HeroPhysic;
     hCam = GetComponent <HeroCamera> () as HeroCamera;
     hClimb = GetComponent <HeroClimb> () as HeroClimb;
     if (hCam.cam)
         cam = hCam.cam;
     bones = GetComponentsInChildren <Transform> () as Transform[];
     foreach (Transform t in bones)
     {
         if (t.name == "root")
             rootB = t;
     }
     // FX
     GameObject gO = (GameObject)Resources.Load( "FX_WaterSurf" );
     surfSplash = (GameObject)Instantiate (gO, hero.position, Quaternion.identity);
     surfSplash.active = false;
 }