Beispiel #1
0
    public void ReleaseHero(FighterHero hero)
    {
        HeroConfig cfg = Config.HeroCfg[hero.ID - 1];

        hero.OnUninit();
        ReleasePrefab(cfg.prefab, hero.gameObject);
    }
Beispiel #2
0
 public override void OnAttach(FighterHero hero)
 {
     base.OnAttach(hero);
     transform.localPosition = new Vector3(0.2f, -0.1f, 0f);
     transform.localRotation = Quaternion.Euler(90, 90, 0);
     transform.localScale    = new Vector3(1f, 1f, 1f);
 }
Beispiel #3
0
 public void Cure(FighterHero hero, int cure)
 {
     if (cure <= 0 || hero.CurHP <= 0 || hero.CurHP >= hero.MaxHP)
     {
         return;
     }
     hero.OnCure(cure);
 }
Beispiel #4
0
 public override void OnAttach(FighterHero hero)
 {
     base.OnAttach(hero);
     transform.localPosition = new Vector3(0.25f, 0f, 0f);
     transform.localRotation = Quaternion.Euler(0, 0, 0);
     transform.localScale    = Vector3.one;
     LoadShell();
 }
Beispiel #5
0
 // 玩家atk击杀了def
 public void OnHeroKill(FighterHero atk, FighterHero def)
 {
     if (def.IsMain)
     {
         // 主角死亡,显示死亡界面
     }
     else
     {
         ResMgr.It.ReleaseHero(def);
     }
 }
Beispiel #6
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.tag != "hero")
        {
            return;
        }
        FighterHero hero = collider.GetComponent <FighterHero>();

        if (OnAttachHero(hero))
        {
            ResMgr.It.ReleaseItem(this);
        }
    }
Beispiel #7
0
    public void Damage(FighterHero atk, FighterHero def, int damage)
    {
        if (damage <= 0 || def.CurHP <= 0)
        {
            return;
        }
        // 伤害公式

        def.OnDamage(damage);
        if (def.CurHP <= 0)
        {
            OnHeroKill(atk, def);
        }
    }
Beispiel #8
0
    public FighterHero AddHero(bool isMain, int id, float x, float z, int fid, string name, int hp, int maxhp)
    {
        if (fid <= 0)
        {
            fid = NewFid();
        }
        FighterHero hero = ResMgr.It.CreateHero(id, x, z, fid, name, hp, maxhp);

        hero.IsMain = isMain;
        m_Heros.Add(fid, hero);
        if (isMain)
        {
            m_MainHero = hero;
            UpdateCamera();
        }
        return(hero);
    }
Beispiel #9
0
    public FighterHero CreateHero(int id, float x, float z, int fid, string name, int hp, int maxhp)
    {
        HeroConfig  cfg  = Config.HeroCfg[id - 1];
        GameObject  obj  = CreatePrefab(cfg.prefab);
        FighterHero hero = obj.GetComponent <FighterHero>();

        hero.transform.parent     = GameMgr.It.ObjRoot;
        hero.transform.rotation   = Quaternion.identity;
        hero.transform.position   = new Vector3(x, 2, z);
        hero.transform.localScale = new Vector3(2, 2, 2);
        hero.gameObject.SetActive(true);
        hero.Fid  = fid;
        hero.ID   = id;
        hero.Name = name;
        hero.name = "hero_" + fid;
        hero.OnInit(hp, maxhp);
        return(hero);
    }
Beispiel #10
0
    public override void OnStart()
    {
        base.OnStart();
        // 创建主角,并将镜头绑定到主角头上
        FighterHero obj = GameMgr.It.AddHero(true, 1, 0, 0, 0, "哈哈", 5, 5);

        obj.ChangeWeapon(1);
        for (int i = 0; i < 20; i++)
        {
            obj = GameMgr.It.AddHero(false, 1, Random.Range(-20f, 20f), Random.Range(-20f, 20f),
                                     0, "吼吼", 5, 5);
            obj.InitAI(true);
            obj.ChangeWeapon(-1);
        }

        for (int i = 0; i < 30; i++)
        {
            ResMgr.It.CreateItem(2, Random.Range(-20f, 20f), Random.Range(-20f, 20f));
        }
    }
Beispiel #11
0
 public override bool OnAttachHero(FighterHero hero)
 {
     //CombatMgr.It.Cure(hero, 10);
     hero.AddExp(1);
     return(true);
 }
Beispiel #12
0
 public void OnMove(FighterHero hero, float x, float z)
 {
     hero.MoveBy(x, z);
     UpdateCamera();
 }
Beispiel #13
0
 // 玩家升级
 public void OnHeroLevelup(FighterHero hero)
 {
 }
Beispiel #14
0
 // 返回true/false,表示是否需要销毁道具
 public virtual bool OnAttachHero(FighterHero hero)
 {
     return(true);
 }
Beispiel #15
0
 // 解除和玩家的绑定
 public virtual void OnDetach()
 {
     Owner            = null;
     transform.parent = null;
 }
Beispiel #16
0
 // 绑定到玩家身上
 public virtual void OnAttach(FighterHero hero)
 {
     Owner            = hero;
     transform.parent = hero.transform;
     IsShooting       = false;
 }
Beispiel #17
0
 public override bool OnAttachHero(FighterHero hero)
 {
     GameMgr.It.Cure(hero, 10);
     return(true);
 }
Beispiel #18
0
 public void OnMoveStart(FighterHero hero)
 {
     hero.MoveStart();
 }
Beispiel #19
0
 public void OnMoveStop(FighterHero hero)
 {
     hero.MoveStop();
 }