コード例 #1
0
    private void Awake()
    {
        manager = GameObject.Find("Game Manager").GetComponent <GameManager>();
        UnitAttribute unitAttribute = new UnitAttribute();

        unitAttribute.ResourceName = "Prefabs/Chess Unit";
        unitAttribute.Ascription   = UnitAttribute.UnitAscription.red;
        unitAttribute.UV           = new Pair(2, 0);
        unitAttribute.Higth        = 0.5f;
        GameObject chessUnit = (GameObject)Resources.Load("Prefabs/Chess Unit");

        unitAttribute.HP              = chessUnit.GetComponent <UnitControler>().attribute.HP;
        unitAttribute.speed           = chessUnit.GetComponent <UnitControler>().attribute.speed;
        unitAttribute.attackStandard  = chessUnit.GetComponent <UnitControler>().attribute.attackStandard;
        unitAttribute.attackDeviation = chessUnit.GetComponent <UnitControler>().attribute.attackDeviation;
        manager.SetUnit(unitAttribute);
        InserUnit(unitAttribute);
        unitAttribute = new UnitAttribute();
        unitAttribute.ResourceName = "Prefabs/Chess Unit";
        unitAttribute.Ascription   = UnitAttribute.UnitAscription.blue;
        unitAttribute.UV           = new Pair(2, 9);
        unitAttribute.Higth        = 0.5f;
        chessUnit                     = (GameObject)Resources.Load("Prefabs/Chess Unit");
        unitAttribute.HP              = chessUnit.GetComponent <UnitControler>().attribute.HP;
        unitAttribute.speed           = chessUnit.GetComponent <UnitControler>().attribute.speed;
        unitAttribute.attackStandard  = chessUnit.GetComponent <UnitControler>().attribute.attackStandard;
        unitAttribute.attackDeviation = chessUnit.GetComponent <UnitControler>().attribute.attackDeviation;
        manager.SetUnit(unitAttribute);
        InserUnit(unitAttribute);
        unitAttribute = new UnitAttribute();
        unitAttribute.ResourceName = "Prefabs/Long Range";
        unitAttribute.Ascription   = UnitAttribute.UnitAscription.blue;
        unitAttribute.UV           = new Pair(6, 9);
        unitAttribute.Higth        = 0.5f;
        chessUnit                        = (GameObject)Resources.Load("Prefabs/Long Range");
        unitAttribute.HP                 = chessUnit.GetComponent <UnitControler>().attribute.HP;
        unitAttribute.speed              = chessUnit.GetComponent <UnitControler>().attribute.speed;
        unitAttribute.attackStandard     = chessUnit.GetComponent <UnitControler>().attribute.attackStandard;
        unitAttribute.attackDeviation    = chessUnit.GetComponent <UnitControler>().attribute.attackDeviation;
        unitAttribute.longRange          = chessUnit.GetComponent <UnitControler>().attribute.longRange;
        unitAttribute.longRangeStandard  = chessUnit.GetComponent <UnitControler>().attribute.longRangeStandard;
        unitAttribute.longRangeDeviation = chessUnit.GetComponent <UnitControler>().attribute.longRangeDeviation;
        manager.SetUnit(unitAttribute);
        InserUnit(unitAttribute);
        unitAttribute = new UnitAttribute();
        unitAttribute.ResourceName = "Prefabs/Long Range";
        unitAttribute.Ascription   = UnitAttribute.UnitAscription.red;
        unitAttribute.UV           = new Pair(6, 0);
        unitAttribute.Higth        = 0.5f;
        chessUnit                        = (GameObject)Resources.Load("Prefabs/Long Range");
        unitAttribute.HP                 = chessUnit.GetComponent <UnitControler>().attribute.HP;
        unitAttribute.speed              = chessUnit.GetComponent <UnitControler>().attribute.speed;
        unitAttribute.attackStandard     = chessUnit.GetComponent <UnitControler>().attribute.attackStandard;
        unitAttribute.attackDeviation    = chessUnit.GetComponent <UnitControler>().attribute.attackDeviation;
        unitAttribute.longRange          = chessUnit.GetComponent <UnitControler>().attribute.longRange;
        unitAttribute.longRangeStandard  = chessUnit.GetComponent <UnitControler>().attribute.longRangeStandard;
        unitAttribute.longRangeDeviation = chessUnit.GetComponent <UnitControler>().attribute.longRangeDeviation;
        manager.SetUnit(unitAttribute);
        InserUnit(unitAttribute);
    }
コード例 #2
0
    void Update_ReadyState()
    {
        GetMouse GM = gameObject.GetComponent <GetMouse>();

        if (GM.IsPressedMouseButton == false)
        {
            vecPos   = GM.GetTargetPos;
            vecPos.y = transform.position.y;
            if (!Mathf.Approximately(vecPos.x, 0) || !Mathf.Approximately(vecPos.z, 0))
            {
                vecPos.x = vecPos.x - (vecPos.x % 5);
                vecPos.z = vecPos.z - (vecPos.z % 5);
                if (Mathf.Approximately(vecPos.x % 10, 0))
                {
                    vecPos.x += 5;
                }
                if (Mathf.Approximately(vecPos.z % 10, 0))
                {
                    vecPos.z += 5;
                }
                transform.position = vecPos;
            }
        }
        if (GM.IsPressedMouseButton == true)
        {
            UnitAttribute myAttribute = gameObject.GetComponent <UnitAttribute>();
            myAttribute.HP = myAttribute.HpMAX;
            SetState(State.MOVE);
            AlphaChange(1f);
            //gameObject.GetComponent<Collider>().enabled = true;
            gameObject.GetComponent <GetMouse>().enabled = false;
        }
    }
コード例 #3
0
    //棋子插入到时间排序链表
    private void InserUnit(UnitAttribute newUnit)
    {
        newUnit.AddSpeedCount();
        LinkedListNode <UnitAttribute> node = unit.First;

        while (node != null)
        {
            if (newUnit.SpeedCount < node.Value.SpeedCount)
            {
                unit.AddBefore(node, newUnit);
                break;
            }
            else if (gameBegin && newUnit.SpeedCount == node.Value.SpeedCount)  //开始时
            {
                if (Random.Range(0, 2) == 0)
                {
                    unit.AddBefore(node, newUnit);
                    break;
                }
            }
            node = node.Next;
        }
        if (node == null)
        {
            unit.AddLast(newUnit);
        }
    }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: xinzhe0822/Chess
    // Use this for initialization
    void Start()
    {
        turnManager = GameObject.Find("Game Manager").GetComponent <TurnManager>();

        mousePosition = new GridPosition(-1, -1);
        //生成全部格子
        for (int i = 0; i < chessWidth; i++)
        {
            for (int j = 0; j < chessHigth; j++)
            {
                GameObject newGrid = Instantiate(grid, gridsContent.transform);
                newGrid.transform.position = new GridPosition(i, j).GetPosition();
                newGrid.SetActive(false);
                grids.Add(new Pair(i, j), newGrid);
            }
        }
        //生成棋子单位
        while (unitQueue.Count != 0)
        {
            UnitAttribute attribute  = unitQueue.Dequeue();
            GameObject    newUnit    = (GameObject)Resources.Load(attribute.ResourceName);
            Quaternion    quaternion = new Quaternion();
            if (attribute.Ascription == UnitAttribute.UnitAscription.blue)
            {
                quaternion = Quaternion.AngleAxis(180f, Vector3.up);
            }
            newUnit = Instantiate(newUnit, new GridPosition(attribute.UV, attribute.Higth).GetPosition(), quaternion, unitContent.transform); //获得创建的object,不然只会修改预设
            newUnit.GetComponent <UnitControler>().Ascription = attribute.Ascription;
            unitObject.AddFirst(newUnit);
            grids[attribute.UV].GetComponent <GridAttribute>().isUnit = true;
        }

        CreatObstacle();
    }
コード例 #5
0
ファイル: QueryController.cs プロジェクト: xareas/framework
        public QueryTokenTS(QueryToken qt, bool recursive)
        {
            this.toStr           = qt.ToString();
            this.niceName        = qt.NiceName();
            this.key             = qt.Key;
            this.fullKey         = qt.FullKey();
            this.type            = new TypeReferenceTS(qt.Type, qt.GetImplementations());
            this.filterType      = QueryUtils.TryGetFilterType(qt.Type);
            this.format          = qt.Format;
            this.unit            = UnitAttribute.GetTranslation(qt.Unit);
            this.typeColor       = qt.TypeColor;
            this.niceTypeName    = qt.NiceTypeName;
            this.queryTokenType  = GetQueryTokenType(qt);
            this.isGroupable     = qt.IsGroupable;
            this.hasOrderAdapter = QueryUtils.OrderAdapters.ContainsKey(qt.Type);

            this.preferEquals = qt.Type == typeof(string) &&
                                qt.GetPropertyRoute() is PropertyRoute pr &&
                                typeof(Entity).IsAssignableFrom(pr.RootType) &&
                                Schema.Current.HasSomeIndex(pr);

            this.propertyRoute = qt.GetPropertyRoute()?.ToString();
            if (recursive && qt.Parent != null)
            {
                this.parent = new QueryTokenTS(qt.Parent, recursive);
            }
        }
コード例 #6
0
ファイル: Character.cs プロジェクト: Tonaplo/RPG
        /// <summary>
        /// The main constructor for a character. All fields must be filled.
        /// </summary>
        /// <param name="_name">The name of the character</param>
        /// <param name="_level">The level of the character granted-</param>
        /// <param name="_basehp">The max amount of health the character</param>
        /// <param name="_curhp">The CURRENT amount of health</param>
        /// <param name="_charclass"> The class of the character</param>
        /// <param name="_curxp">The current amount of experience the character has</param>
        /// <param name="_str">The amount of strength the character has</param>
        /// <param name="_agi">The amount of agility the character has</param>
        /// <param name="_int">The amount of intellingence the character has</param>
        /// <param name="_armor">The armor of the character</param>
        /// <param name="_meleeattack">The melee attack damage of the character</param>
        /// <param name="_gear">The characters current gear</param>
        /// <param name="_gear">The characters inventory</param>
        public Character(string _name, int _level, int _basehp, int _curhp, EnumCharClass _charclass, int _curxp, int _str, int _agi, int _int, int _crit, int _armor, int _meleeattack, Gear _gear)
            : base(_name, _level, _basehp, _curhp)
        {
            this.charClass = _charclass;
            this.charCurrentXP = _curxp;
            this.baseStrength.IntValue = _str;
            this.baseAgility.IntValue = _agi;
            this.baseIntellingence.IntValue = _int;
            this.buffedStrength.IntValue = _str;
            this.buffedAgility.IntValue = _agi;
            this.buffedIntellingence.IntValue = _int;
            this.BaseCrit.IntValue = _crit;
            this.BuffedCrit.IntValue = _crit;
            this.BuffedAttackDamage.IntValue = _meleeattack;
            this.BaseArmor.IntValue = _armor;
            this.BaseAttackDamage.IntValue = _meleeattack;
            this.BuffedArmor.IntValue = _armor;
            this.BuffedAttackDamage.IntValue = _meleeattack;

            if (_gear == null)
                this.charGear = new Gear();
            else
                this.charGear = _gear;
            this.baseTurnPoints.IntValue = (this.UnitLevel / 10) + 1;
            this.currentTurnPoints = this.baseTurnPoints;

            this.UnitBuffsAndDebuffs = new List<Abilities.BuffsAndDebuffs>();
        }
コード例 #7
0
ファイル: UnitAi.cs プロジェクト: seonwifi/bongbong
    public void Init(Unit myUnit, UnitSearch searcher)
    {
        m_unit      = myUnit;
        m_unit.m_ai = this;

        m_enermySearcher = searcher;
        if (m_enermySearcher)
        {
            m_enermySearcher.m_myAi = this;
        }

        m_AiProcessList.Capacity = (int)eAiProcess.Max;

        for (int i = 0; i < (int)eAiProcess.Max; ++i)
        {
            m_AiProcessList.Add(null);
        }

        AddState(eAiProcess.come_into_the_world, new AiProcessComeIntoTheWorld(eAiProcess.fly_run));
        AddState(eAiProcess.idle, new AiProcessIdle());
        AddState(eAiProcess.run, new AiProcessMoving());
        AddState(eAiProcess.attack, new AiProcessAttack());
        AddState(eAiProcess.die, new AiProcessDie());
        AddState(eAiProcess.fly_run, new AiFlyMoving());
        AddState(eAiProcess.fly_attack, new AiFlyAttack());
        AddState(eAiProcess.fly_idle, new AiFlyIdle());
        AddState(eAiProcess.fly_die, new AiFlyDie());

        SetNextProcess(eAiProcess.come_into_the_world);
        m_UnitAttribute = new UnitAttribute();
    }
コード例 #8
0
    ///<summary>
    ///타겟에게 나의 능력치를 기반하여 HP를 감소시킨다.
    /// </summary>
    void Enter_AttackState()
    {
        UnitAttribute myAttribute = gameObject.GetComponent <UnitAttribute>();

        if (ProcessDeadState(myAttribute))
        {
            return;
        }
        anime.speed = 1 / (myAttribute.AttackTime * 2);
        anime.SetBool("Attack", true);
        UnitAttribute targetAttribute = Target.GetComponent <UnitAttribute>();

        targetAttribute.HP -= myAttribute.AttackPower;
        if (targetAttribute.HP <= 0)
        {
            Target = null;
            //Debug.Log("Target Changed");
            anime.SetBool("Attack", false);
            anime.speed = 0.2f;
            StartCoroutine("TransStateToMove", 0.5f);
        }
        else
        {
            StartCoroutine("TransStateToMove", myAttribute.AttackTime);
        }
    }
コード例 #9
0
        public int GetAttributeBase(UnitAttribute attribute)
        {
            switch (attribute)
            {
            case UnitAttribute.None:               return(0);

            case UnitAttribute.MaxHP:              return(BaseUnitData.HP);

            case UnitAttribute.MaxSP:              return(BaseUnitData.SP);

            case UnitAttribute.Physical:           return(BaseUnitData.Physical);

            case UnitAttribute.Magic:              return(BaseUnitData.Magic);

            case UnitAttribute.Defense:            return(BaseUnitData.Defense);

            case UnitAttribute.Resistance:         return(BaseUnitData.Resistance);

            case UnitAttribute.Skill:              return(BaseUnitData.Skill);

            case UnitAttribute.Speed:              return(BaseUnitData.Speed);

            case UnitAttribute.Luck:               return(BaseUnitData.Luck);

            case UnitAttribute.Movement:           return(BaseUnitData.MovementSpeed);

            case UnitAttribute.WalkingDamage:      return(BaseUnitData.BonusWalkingDamage);

            case UnitAttribute.WalkingDamageRange: return(BaseUnitData.BonusWalkingDamageRange);

            default: throw new NotImplementedException(string.Format("Attribute: {0} not implemented in Unit:GetAttributeBase function", attribute));
            }
        }
コード例 #10
0
 public int GetAttributeFromGains(UnitAttribute attribute)
 {
     if (!AttributesGains.ContainsKey(attribute))
     {
         return(0);
     }
     return(AttributesGains[attribute]);
 }
コード例 #11
0
 public int GetAttributeFromLevelUps(UnitAttribute attribute)
 {
     if (!AttributesLevels.ContainsKey(attribute))
     {
         return(0);
     }
     return(AttributesLevels[attribute]);
 }
コード例 #12
0
    public void Attack(Collider target)
    {
        UnitAttribute enemy = target.GetComponentInParent <UnitAttribute>();

        unitAttribute.wanderNPC.enabled = false;
        transform.position = Vector3.MoveTowards(transform.position, target.transform.position, 2 * Time.deltaTime);
        enemy.beingAttacked(20);
        print(enemy.health);
    }
コード例 #13
0
ファイル: GameManager.cs プロジェクト: xinzhe0822/Chess
    //由服务器(现在时模拟服务器的脚本TurnManager)传输数据初始化要显示的棋子的队列
    public void SetUnit(string resourceName, UnitAttribute.UnitAscription ascription, Pair UV, float higth)
    {
        UnitAttribute unit = new UnitAttribute();

        unit.ResourceName = resourceName;
        unit.Ascription   = ascription;
        unit.UV           = UV;
        unit.Higth        = higth;
        unitQueue.Enqueue(unit);
    }
コード例 #14
0
 ///<summary>
 ///내가 사망했는지 체크하고, 사망한 경우는 코루틴으로 지연되는 처리를 모두 중지시키고, 사망 상태로만 전이시킨다.
 ///</summary>
 ///<param name = "myAttribute"></param>
 ///<returns></returns>
 bool ProcessDeadState(UnitAttribute myAttribute)
 {
     if (myAttribute.HP <= 0)
     {
         StopAllCoroutines();
         SetState(State.DEAD);
         return(true);
     }
     return(false);
 }
コード例 #15
0
        /// <summary>
        /// Gets the unit type of quantity type parameter based on SI unit system.
        /// The function is direct mapping from types of quantities to types of units.
        /// if function returns null then this quantity dosen't have a statically linked unit to it.
        /// this means the quantity should return a unit in runtime.
        /// </summary>
        /// <param name="qType">Type of Quantity</param>
        /// <returns>SI Unit Type</returns>
        public static Type GetDefaultSIUnitTypeOf(Type qType)
        {
            Type quantityType = qType;


            //getting the generic type
            if (!quantityType.IsGenericTypeDefinition)
            {
                //the passed type is AnyQuantity<object> for example
                //I want to get the type without type parameters AnyQuantity<>

                quantityType = quantityType.GetGenericTypeDefinition();
            }

            //don't forget to include second in si units it is shared between all metric systems
            var SIUnitTypes = from si in UnitTypes
                              where si.Namespace.ToUpperInvariant().EndsWith("SI", StringComparison.Ordinal) || si.Namespace.ToUpperInvariant().EndsWith("SHARED", StringComparison.Ordinal)
                              select si;



            Func <Type, bool> SearchForQuantityType = unitType =>
            {
                //search in the attributes of the unit type
                MemberInfo info = unitType as MemberInfo;

                object[] attributes = (object[])info.GetCustomAttributes(true);

                //get the UnitAttribute
                UnitAttribute ua = (UnitAttribute)attributes.SingleOrDefault <object>(ut => ut is UnitAttribute);

                if (ua != null)
                {
                    if (ua.QuantityType == quantityType)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            };


            Type SIUnitType = SIUnitTypes.SingleOrDefault(
                SearchForQuantityType
                );

            return(SIUnitType);
        }
コード例 #16
0
ファイル: ReflectionServer.cs プロジェクト: m-adi/framework
        public static Dictionary <string, TypeInfoTS> GetEntities(IEnumerable <Type> allTypes)
        {
            var models = (from type in allTypes
                          where typeof(ModelEntity).IsAssignableFrom(type) && !type.IsAbstract
                          select type).ToList();

            var queries = QueryLogic.Queries;

            var schema   = Schema.Current;
            var settings = Schema.Current.Settings;

            var result = (from type in TypeLogic.TypeToEntity.Keys.Concat(models)
                          where !type.IsEnumEntity() && !ReflectionServer.ExcludeTypes.Contains(type)
                          let descOptions = LocalizedAssembly.GetDescriptionOptions(type)
                                            let allOperations = !type.IsEntity() ? null : OperationLogic.GetAllOperationInfos(type)
                                                                select KVP.Create(GetTypeName(type), OnAddTypeExtension(new TypeInfoTS
            {
                Kind = KindOfType.Entity,
                FullName = type.FullName,
                NiceName = descOptions.HasFlag(DescriptionOptions.Description) ? type.NiceName() : null,
                NicePluralName = descOptions.HasFlag(DescriptionOptions.PluralDescription) ? type.NicePluralName() : null,
                Gender = descOptions.HasFlag(DescriptionOptions.Gender) ? type.GetGender().ToString() : null,
                EntityKind = type.IsIEntity() ? EntityKindCache.GetEntityKind(type) : (EntityKind?)null,
                EntityData = type.IsIEntity() ? EntityKindCache.GetEntityData(type) : (EntityData?)null,
                IsLowPopulation = type.IsIEntity() ? EntityKindCache.IsLowPopulation(type) : false,
                IsSystemVersioned = type.IsIEntity() ? schema.Table(type).SystemVersioned != null : false,
                ToStringFunction = typeof(Symbol).IsAssignableFrom(type) ? null : LambdaToJavascriptConverter.ToJavascript(ExpressionCleaner.GetFieldExpansion(type, miToString)),
                QueryDefined = queries.QueryDefined(type),
                Members = PropertyRoute.GenerateRoutes(type).Where(pr => InTypeScript(pr))
                          .ToDictionary(p => p.PropertyString(), p =>
                {
                    var mi = new MemberInfoTS
                    {
                        NiceName = p.PropertyInfo?.NiceName(),
                        TypeNiceName = GetTypeNiceName(p.PropertyInfo?.PropertyType),
                        Format = p.PropertyRouteType == PropertyRouteType.FieldOrProperty ? Reflector.FormatString(p) : null,
                        IsReadOnly = !IsId(p) && (p.PropertyInfo?.IsReadOnly() ?? false),
                        Unit = UnitAttribute.GetTranslation(p.PropertyInfo?.GetCustomAttribute <UnitAttribute>()?.UnitName),
                        Type = new TypeReferenceTS(IsId(p) ? PrimaryKey.Type(type).Nullify() : p.PropertyInfo?.PropertyType, p.Type.IsMList() ? p.Add("Item").TryGetImplementations() : p.TryGetImplementations()),
                        IsMultiline = Validator.TryGetPropertyValidator(p)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault()?.MultiLine ?? false,
                        MaxLength = Validator.TryGetPropertyValidator(p)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault()?.Max.DefaultToNull(-1),
                        PreserveOrder = settings.FieldAttributes(p)?.OfType <PreserveOrderAttribute>().Any() ?? false,
                    };

                    return(OnAddPropertyRouteExtension(mi, p));
                }),

                Operations = allOperations == null ? null : allOperations.ToDictionary(oi => oi.OperationSymbol.Key, oi => OnAddOperationExtension(new OperationInfoTS(oi), oi, type)),

                RequiresEntityPack = allOperations != null && allOperations.Any(oi => oi.HasCanExecute != null),
            }, type))).ToDictionaryEx("entities");

            return(result);
        }
コード例 #17
0
ファイル: CombatUnit.cs プロジェクト: kblood/TyrSc2
 public bool HasAttribute(UnitAttribute attribute)
 {
     foreach (UnitAttribute attr in Attributes)
     {
         if (attr.Equals(attribute))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #18
0
        /// <summary>
        ///  Unit order converter
        /// </summary>
        /// <param name="items"></param>
        /// <param name="units">Kind of split unit to use</param>
        /// <returns></returns>
        public static Int64 unitConverter(Int64 items, SplitUnit units)
        {
            Int64 result = items;
            var   info   = UnitAttribute.GetFromField <SplitUnit>(units);

            if (info.Factor > 0)
            {
                result = (Int64)Math.Ceiling(items * info.CalculatedFactor);
            }
            return(result);
        }
コード例 #19
0
ファイル: Aura.cs プロジェクト: ndssia/Corsair3
        public Aura(string name, OperationType opType, int amount, UnitAttribute attribute, bool repeating, float duration)
        {
            Texture = Game1.ContentManager.Load<Texture2D>("Textures/effects");

            Name = name;
            OpType = opType;
            Amount = amount;
            Attribute = attribute;
            Duration = duration;
            Repeating = repeating;
        }
コード例 #20
0
ファイル: Common.cs プロジェクト: sizzles/framework
 static void TaskSetUnitText(FrameworkElement fe, string route, PropertyRoute context)
 {
     if (fe is ValueLine vl && vl.NotSet(ValueLine.UnitTextProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
     {
         UnitAttribute ua = context.PropertyInfo.GetCustomAttribute <UnitAttribute>();
         if (ua != null)
         {
             vl.UnitText = ua.UnitName;
         }
     }
 }
コード例 #21
0
    public void SetAllUnit(Dictionary <string, object> infos)
    {
        List <object> listinfos = (List <object>)infos["values"];
        UnitAttribute unitAttribute;

        for (int i = 0; i < listinfos.Count; i++)
        {
            unitAttribute = new UnitAttribute((Dictionary <string, object>)listinfos[i]);
            unitQueue.Enqueue(unitAttribute);
        }

        CreatUnit();
    }
コード例 #22
0
 // Update is called once per frame
 void Update()
 {
     if (turnFlag)
     {
         turnFlag = false;
         if (unit.First != null)
         {
             turnUnit = unit.First.Value;
             manager.SetTurnUnit(turnUnit);
             unit.RemoveFirst();
         }
     }
 }
コード例 #23
0
ファイル: Common.cs プロジェクト: jeason0813/framework-2
        static void TaskSetUnitText(LineBase bl)
        {
            ValueLine vl = bl as ValueLine;

            if (vl != null && vl.PropertyRoute.PropertyRouteType == PropertyRouteType.FieldOrProperty)
            {
                UnitAttribute ua = bl.PropertyRoute.PropertyInfo.GetCustomAttribute <UnitAttribute>();
                if (ua != null)
                {
                    vl.UnitText = ua.UnitName;
                }
            }
        }
コード例 #24
0
    void Enter_MoveState()
    {
        UnitAttribute myAttribute = gameObject.GetComponent <UnitAttribute>();

        if (ProcessDeadState(myAttribute))
        {
            return;
        }
        anime.speed = 1.0f;
        anime.SetBool("Move", true);

        Update_MoveState();
    }
コード例 #25
0
        /// <summary>
        /// Find Strongly typed unit.
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        private static Unit FindUnit(string un)
        {
            string unit = un.Replace("$", "\\$");


            bool UnitModifier = false;

            if (unit.EndsWith("!", StringComparison.Ordinal))
            {
                //it is intended of Radius length
                unit         = unit.TrimEnd('!');
                UnitModifier = true; //unit modifier have one use for now is to convert the Length Quantity into Length Quantity into RadiusLength quantity
            }

            foreach (Type unitType in UnitTypes)
            {
                UnitAttribute ua = GetUnitAttribute(unitType);
                if (ua != null)
                {
                    //units are case sensitive

                    if (Regex.Match(ua.Symbol, "^" + unit + "$", RegexOptions.Singleline).Success)
                    {
                        Unit u = (Unit)Activator.CreateInstance(unitType);

                        //test unit if it is metric so that we remove the default prefix that created with it
                        if (u is MetricUnit)
                        {
                            ((MetricUnit)u).UnitPrefix = MetricPrefix.None;
                        }


                        if (UnitModifier)
                        {
                            //test if the dimension is length and modify it to be radius length
                            if (u.QuantityType == typeof(Length <>))
                            {
                                u.QuantityType = typeof(PolarLength <>);
                            }
                        }


                        return(u);
                    }
                }
            }

            throw new UnitNotFoundException(un);
        }
コード例 #26
0
    //处理棋子攻击
    public void UnitAttack(Pair UV, bool flag)
    {
        LinkedListNode <UnitAttribute> node = unit.First;

        while (node != null)
        {
            if (node.Value.UV.Equals(UV))
            {
                break;
            }
            node = node.Next;
        }
        UnitAttribute attribute = node.Value;
        int           damage;

        if (flag)
        {
            damage = Random.Range(turnUnit.attackStandard - turnUnit.attackDeviation, turnUnit.attackStandard + turnUnit.attackDeviation + 1);
        }
        else
        {
            damage = Random.Range(turnUnit.longRangeStandard - turnUnit.longRangeDeviation, turnUnit.longRangeStandard + turnUnit.longRangeDeviation + 1);
            int distance = turnUnit.UV.GetDistance(UV);
            if (distance > turnUnit.longRange)
            {
                if (distance > 2 * turnUnit.longRange)
                {
                    damage *= 3 / 10;
                }
                else
                {
                    damage = damage * (distance - turnUnit.longRange) * 7 / (10 * turnUnit.longRange);
                }
            }
        }
        attribute.HP -= damage;
        bool deadFlag = false;

        if (attribute.HP <= 0)
        {
            unit.Remove(node);
            deadFlag = true;
        }
        else
        {
            node.Value = attribute;
        }
        manager.UnitUnderAttack(damage, deadFlag);
    }
コード例 #27
0
        /// <summary>
        ///  Unit order converter
        /// </summary>
        /// <param name="items"></param>
        /// <param name="units">Kind of split unit to use</param>
        /// <returns></returns>
        public static Int64 unitConverter(Int64 items, SplitUnit units)
        {
            Int64 result = items;

            // Make sure to check if it's something valid we can split
            if (units != SplitUnit.Incorrect)
            {
                var info = UnitAttribute.GetFromField <SplitUnit>(units);
                // If the GetFromField fails; make sure to test it's not null
                if (info != null && info.Factor > 0)
                {
                    result = (Int64)Math.Ceiling(items * info.CalculatedFactor);
                }
            }
            return(result);
        }
コード例 #28
0
ファイル: Unit.cs プロジェクト: KryptixRL/AAEmu
        public override void RemoveBonus(uint bonusIndex, UnitAttribute attribute)
        {
            if (!Bonuses.ContainsKey(bonusIndex))
            {
                return;
            }
            var bonuses = Bonuses[bonusIndex];

            foreach (var bonus in new List <Bonus>(bonuses))
            {
                if (bonus.Template != null && bonus.Template.Attribute == attribute)
                {
                    bonuses.Remove(bonus);
                }
            }
        }
コード例 #29
0
 //生成棋子单位
 public void CreatUnit()
 {
     while (unitQueue.Count != 0)
     {
         UnitAttribute attribute  = unitQueue.Dequeue();
         GameObject    newUnit    = (GameObject)Resources.Load("Prefabs/" + attribute.ResourceName);
         Quaternion    quaternion = new Quaternion();
         if (attribute.Ascription == UnitAttribute.UnitAscription.blue)
         {
             quaternion = Quaternion.AngleAxis(180f, Vector3.up);
         }
         newUnit = Instantiate(newUnit, new GridPosition(attribute.UV, attribute.Higth).GetPosition(), quaternion, unitContent.transform); //获得创建的object,不然只会修改预设
         newUnit.GetComponent <UnitControler>().attribute = attribute;
         unitObject.AddFirst(newUnit);
         grids[attribute.UV].GetComponent <GridAttribute>().isUnit = true;
     }
 }
コード例 #30
0
ファイル: Common.cs プロジェクト: sizzles/framework
        public static void TaskDataGridColumnSetLabelText(DataGridColumn col, string route, PropertyRoute context)
        {
            DependencyProperty labelText = DataGridColumn.HeaderProperty;

            if (labelText != null && col.NotSet(labelText))
            {
                string text = context.PropertyInfo.NiceName();

                UnitAttribute ua = context.PropertyInfo.GetCustomAttribute <UnitAttribute>();
                if (ua != null)
                {
                    text += " (" + ua.UnitName + ")";
                }

                col.SetValue(labelText, text);
            }
        }
コード例 #31
0
    void Update_MoveState()
    {
        UnitAttribute myAttribute = gameObject.GetComponent <UnitAttribute>();

        if (ProcessDeadState(myAttribute))
        {
            return;
        }
        //타겟이 계속 바뀌면 안됨으로,타겟이 유효한 경우는 유지되도록


        bool isFindTarget = false;

        if (Target != null)
        {
            UnitAttribute targetAttribute = Target.GetComponent <UnitAttribute>();
            if (targetAttribute.HP > 0)
            {
                isFindTarget = true;
            }
        }
        if (!isFindTarget)
        {
            Target = FindEnemy_MKII();
        }
        if (Target != null)
        {
            UnitAttribute targetAttribute = Target.GetComponent <UnitAttribute>();
            if (targetAttribute.HP <= 0)
            {
                return;
            }
            else if (nextAttackCooltime_ == 0.0f || nextAttackCooltime_ < Time.time)
            {
                nextAttackCooltime_ = Time.time + myAttribute.AttackTime;
                SetState(State.ATTACK);
            }
        }
        else
        {
            transform.Translate(Vector3.forward.normalized * myAttribute.MoveSpeed * Time.deltaTime);
        }
    }
コード例 #32
0
ファイル: Unit.cs プロジェクト: KryptixRL/AAEmu
        public List <Bonus> GetBonuses(UnitAttribute attribute)
        {
            var result = new List <Bonus>();

            if (Bonuses == null)
            {
                return(result);
            }
            foreach (var bonuses in new List <List <Bonus> >(Bonuses.Values))
            {
                foreach (var bonus in new List <Bonus>(bonuses))
                {
                    if (bonus.Template != null && bonus.Template.Attribute == attribute)
                    {
                        result.Add(bonus);
                    }
                }
            }
            return(result);
        }
コード例 #33
0
ファイル: Unit.cs プロジェクト: ndssia/Corsair3
        public void RecalculateAttribute(UnitAttribute attribute)
        {
            if (attribute == UnitAttribute.Health)
                return;

            Attribute[attribute] = BaseAttribute[attribute];
            foreach (var aura in Auras) {
                if (aura.Attribute == attribute && !aura.Expired)
                    aura.Apply(this);
            }
        }
コード例 #34
0
ファイル: UnitAi.cs プロジェクト: seonwifi/bongbong
    public void Init(Unit myUnit, UnitSearch searcher)
    {
        m_unit 				= myUnit;
        m_unit.m_ai 		= this;

        m_enermySearcher 	= searcher;
        if(m_enermySearcher)m_enermySearcher.m_myAi		= this;

        m_AiProcessList.Capacity = (int)eAiProcess.Max;

        for(int i = 0; i < (int)eAiProcess.Max; ++i)
        {
            m_AiProcessList.Add(null);
        }

        AddState( eAiProcess.come_into_the_world, new AiProcessComeIntoTheWorld(eAiProcess.fly_run));
        AddState( eAiProcess.idle, new AiProcessIdle());
        AddState( eAiProcess.run, new AiProcessMoving());
        AddState( eAiProcess.attack, new AiProcessAttack());
        AddState( eAiProcess.die, new AiProcessDie());
        AddState( eAiProcess.fly_run, new AiFlyMoving());
        AddState( eAiProcess.fly_attack, new AiFlyAttack());
        AddState( eAiProcess.fly_idle, new AiFlyIdle());
        AddState( eAiProcess.fly_die, new AiFlyDie());

        SetNextProcess (eAiProcess.come_into_the_world);
        m_UnitAttribute = new UnitAttribute ();
    }