Exemplo n.º 1
0
    //=================================================================================================================o
    void Start()
    {
        hero = transform;

        hCtrl = GetComponent <HeroCtrl>() as HeroCtrl;


        Vector3 angls = cam.eulerAngles;

        xAngl = angls.x;
        yAngl = angls.y;

        curDist   = heroDistance;
        desDist   = heroDistance;
        finalDist = heroDistance;

        //cam.camera.nearClipPlane = 0.01f;

        //Screen.lockCursor = true;
        Cursor.visible = false;

        // if no headbone search for it
        if (headBone == null)
        {
            Transform[] bones = GetComponentsInChildren <Transform>() as Transform[];
            foreach (Transform t in bones)
            {
                if (t.name == "head")
                {
                    headBone = t;
                }
            }
        }
    }
Exemplo n.º 2
0
    public void RebirthHero(int heroId)
    {
        if (!CtrlDict.ContainsKey(heroId))
        {
            return;
        }

        HeroCtrl hero = CtrlDict[heroId] as HeroCtrl;

        // 设置位置
        if (hero.Model.Team == 1)
        {
            hero.transform.position = Team1HeroPoint[0].position;
        }
        else if (hero.Model.Team == 2)
        {
            hero.transform.position = Team2HeroPoint[0].position;
        }

        // 设置层
        if (hero.Model.Team == GameData.HeroData.Team)
        {
            hero.gameObject.layer = LayerMask.NameToLayer("Friend");
        }
        else
        {
            hero.gameObject.layer = LayerMask.NameToLayer("Enemy");
        }

        hero.RebirthResponse();
    }
Exemplo n.º 3
0
    void Start()
    {
        personCtrl        = this.GetComponent <HeroCtrl>();
        heroStateActVer   = new IdleStateActVer(this.gameObject);
        heroStateMoveVer  = new IdleStateMoveVer(this.gameObject);
        inputArgs         = new InputEventArgs("", "", "");
        hero_act_state[0] = new IdleStateActVer(this.gameObject);
        hero_act_state[1] = new ActState(this.gameObject);
        hero_act_state[2] = new DefenseState(this.gameObject);

        hero_move_state[0] = new IdleStateMoveVer(this.gameObject);
        hero_move_state[1] = new MoveState(this.gameObject);
        hero_move_state[2] = new JumpState(this.gameObject);

        InputTran += new InputEventHandler(heroStateActVer.handleInput);
        InputTran += new InputEventHandler(heroStateMoveVer.handleInput);
    }
Exemplo n.º 4
0
    public void OnTriggerEnter2D(Collider2D coll)
    {
        if (!isFallTrigger)
        {
            HeroCtrl ctrl = coll.GetComponent <HeroCtrl>();
            if (ctrl != null && ctrl.playerRigidbody2D.velocity.y < 0)
            {
                return;
            }
        }
        TriggerEvent.Invoke();

        SoundManager.Instance.PlaySound(AudioName);

        if (eventId != EventDef.LevelEvent.None)
        {
            SendEvent();
        }
    }
Exemplo n.º 5
0
    void Awake()
    {
        instance = this;

        heroPosition = this.transform.position;


        if (AppMgr.Instance.HeroPos == Vector3.zero)
        {
            AppMgr.Instance.HeroPos = transform.position;
        }
        else
        {
            transform.position = AppMgr.Instance.HeroPos;
        }

        if (AppMgr.Instance)
        {
            AppMgr.Instance.AttachEventListener((int)EventDef.LevelEvent.PlayerDie, this);
            AppMgr.Instance.AttachEventListener((int)EventDef.LevelEvent.GameOver, this);
            AppMgr.Instance.AttachEventListener((int)EventDef.LevelEvent.SaveGame, this);
        }
    }
Exemplo n.º 6
0
    void Start()
    {
        personCtrl = this.GetComponent<HeroCtrl>();
        heroStateActVer = new IdleStateActVer(this.gameObject);
        heroStateMoveVer = new IdleStateMoveVer(this.gameObject);
        inputArgs = new InputEventArgs("", "", "");
        hero_act_state[0] = new IdleStateActVer(this.gameObject);
        hero_act_state[1] = new ActState(this.gameObject);
        hero_act_state[2] = new DefenseState(this.gameObject);

        hero_move_state[0] = new IdleStateMoveVer(this.gameObject);
        hero_move_state[1] = new MoveState(this.gameObject);
        hero_move_state[2] = new JumpState(this.gameObject);

        InputTran += new InputEventHandler(heroStateActVer.handleInput);
        InputTran += new InputEventHandler(heroStateMoveVer.handleInput);
    }
    //=================================================================================================================o
    void Start()
    {
        hero = transform;

        hCtrl = GetComponent <HeroCtrl>() as HeroCtrl;

        Vector3 angls = cam.eulerAngles;
        xAngl = angls.x;
        yAngl = angls.y;

        curDist = heroDistance;
        desDist = heroDistance;
        finalDist = heroDistance;

        //cam.camera.nearClipPlane = 0.01f;

        //Screen.lockCursor = true;
        Cursor.visible = false;

        // if no headbone search for it
        if (headBone == null) {
            Transform[] bones = GetComponentsInChildren <Transform>() as Transform[];
            foreach (Transform t in bones) {
                if (t.name == "head")
                    headBone = t;
            }
        }
    }