Beispiel #1
0
 public override void InjectVO(UnitVO input)
 {
     type = ComponentType.Avatar;
     switch (input.type)
     {
     case UnitType.creature:
         CreatureVO vo = input as CreatureVO;
         foreach (var an in vo.anims)
         {
             Dictionary <AnimType, AnimationData> diction = new Dictionary <AnimType, AnimationData>();
             AnimationData data = new AnimationData();
             if (!animations.TryGetValue(an.avatarType, out diction))
             {
                 if (!diction.TryGetValue(an.animationType, out data))
                 {
                     data = an;
                 }
                 else
                 {
                     data = new AnimationData();
                     data = an;
                     diction.Add(an.animationType, data);
                 }
             }
             else
             {
                 diction = new Dictionary <AnimType, AnimationData>();
                 data    = new AnimationData();
                 diction.Add(an.animationType, data);
                 data = an;
             }
         }
         break;
     }
 }
Beispiel #2
0
    public override void InjectVO(UnitVO input)
    {
        type = ComponentType.Movement;
        switch (input.type)
        {
        case UnitType.creature:
            CreatureVO vo = input as CreatureVO;
            data.position = vo.positon;
            data.forward  = vo.forward;
            data.speed    = vo.speed;
            data.movetype = vo.movetype;
            data.bodySize = vo.bodysize;
            data.type     = UnitType.creature;
            break;

        case UnitType.effect:
            EffectVO evo = input as EffectVO;
            data.position = evo.positon;
            data.forward  = evo.forward;
            data.speed    = evo.speed;
            data.movetype = evo.movetype;
            data.bodySize = evo.bodysize;
            data.type     = UnitType.effect;
            break;
        }
    }
Beispiel #3
0
    public virtual void InjectVO(UnitVO vo)
    {
        List <BaseComponent> coms = entity.GetAllComponents();

        group = vo.group;
        foreach (var com in coms)
        {
            com.InjectVO(vo);
        }
    }
Beispiel #4
0
        /// <summary>
        /// Create a new Unit and initialize default equipment and weapons
        /// </summary>
        public Unit CreateNewUnit(string unitUID, string characterUID, CombatantFactionEnum faction)
        {
            UnitVO      unitVO = metadataMap.GetVO <UnitVO>(unitUID);
            CharacterVO charVO = metadataMap.GetVO <CharacterVO>(characterUID);

            List <Equipment> defaultEquipment = GetEquipmentListFromUIDs(unitVO.equipmentUIDs);

            List <Equipment> defaultWeapons = GetEquipmentListFromUIDs(unitVO.weaponsUIDs);

            Unit unit = new Unit(unitVO, charVO, faction, defaultEquipment, defaultWeapons);

            return(unit);
        }
Beispiel #5
0
    public void CreateUnit(UnitVO data)
    {
        BaseUnit unit = unitFactory.Get(data.type);

        unit.InjectVO(data);
        if (unit != null)
        {
            addCache.Add(unit);
        }
        else
        {
            Debug.Log("BattleField:::Fail to create unit, due to unit is null");
        }
    }
Beispiel #6
0
    //===================== unit function ================================

    public void CreateUnit(int uid, UnitVO unitVO, MapCoordinates createPos)
    {
        ResourceManager.Instance.LoadAssetAsync(unitVO.prefabPath, (asset) =>
        {
            GameObject obj    = Instantiate(asset) as GameObject;
            UnitAvatar avatar = obj.AddComponent <UnitAvatar>();
            avatar.UnitPos    = createPos;
            Unit unit         = new Unit();
            unit.vo           = unitVO;
            unit.avatar       = avatar;
            unit.pos          = createPos;
            unitMap.Add(uid, unit);
            obj.transform.SetParent(mapGrid.MapUnitRoot.transform);
            obj.transform.position = createPos.WorldPosition;
            SetMapCellState(createPos, MapCellState.Occupy);
            GetMapCellData(createPos).unit = unit;
        });
    }
Beispiel #7
0
 public override void InjectVO(UnitVO input)
 {
     type = ComponentType.Health;
     switch (input.type)
     {
     case UnitType.creature:
         CreatureVO vo = input as CreatureVO;
         basedata.hp        = vo.hp;
         basedata.maxHp     = vo.maxHp;
         basedata.attr      = vo.attr;
         basedata.physicDef = vo.physicDef;
         basedata.magicDef  = vo.magicDef;
         realdata.hp        = vo.hp;
         realdata.maxHp     = vo.maxHp;
         realdata.attr      = vo.attr;
         realdata.physicDef = vo.physicDef;
         realdata.magicDef  = vo.magicDef;
         break;
     }
 }
Beispiel #8
0
        public Unit(
            UnitVO vo,
            CharacterVO pilot,
            CombatantFactionEnum faction,
            List <Equipment> equipment,
            List <Equipment> weapons)
        {
            this.vo = vo;

            this.pilot   = pilot;
            this.faction = faction;

            // Initialize the unit with max supplies
            hp   = vo.hp;
            ammo = vo.ammo;
            fuel = vo.fuel;

            this.equipment = equipment;
            this.weapons   = weapons;
        }
Beispiel #9
0
 public override void InjectVO(UnitVO vo)
 {
     base.InjectVO(vo);
 }
Beispiel #10
0
 public virtual void InjectVO(UnitVO vo)
 {
 }