Beispiel #1
0
    public void updatePart()
    {
        PartAction partData = this._person.playerEntity.partGroup.getPart(type);

        if (partData == this._partData)
        {
            return;
        }

        this._partData = partData;
        if (null == this._partData)
        {
            return;
        }


        Image fg = Tools.FindChild2("Fill Area/Fill", this._slider.gameObject).GetComponent <Image>();

        /*************************禁用装备******************************/
        if (this._partData.alived)
        {
            //this.changeImage("Fill Area/Fill", "hpFg10");
            fg.color = this._person.playerEntity.getTeamColor(3);
        }
        else
        {
            fg.color = ViewConstant.COLOR_READY;
            /*************************启用用装备******************************/
            this._partData.addListener(EventConstant.ALIVED, (e) => {
                fg.color = this._person.playerEntity.getTeamColor(3);
            });
        }
        Tools.FindChild2("Background", this._slider.gameObject).GetComponent <Image>().color = this._person.playerEntity.getTeamColor(1);
    }
Beispiel #2
0
    //移除一个部件,并还原默认位置的模型
    public void removePart(int type)
    {
        PartAction part = this.getPart(type);

        Utils.clearObject(part);
        this._parts[type] = null;
    }
Beispiel #3
0
 public SetPropertyDesignerCommand(SnipPageDesigner designer, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod, PartAction action)
 {
     this._designer      = designer;
     this._oldValue      = oldValue;
     this._newValue      = newValue;
     this._setCoreMethod = setCoreMethod;
     this._action        = action;
 }
Beispiel #4
0
 //获得装备当前状态下的攻击力比率
 private double getPartAttackPer(PartAction part)
 {
     if (part.alived)
     {
         return(Math.Pow(getPartHpPer(part), 0.05));
     }
     else
     {
         return(this.getPartCompletePer(part) * 0.7);
     }
 }
Beispiel #5
0
    //添加一个部件
    public void addPart(Dictionary <string, object> partData)
    {
        int type = (int)(partData["position"]);

        //查找到 前缀名字 来判断类型 0 head 1 wing 2 tail
        this.removePart(type);
        PartAction part = (PartAction)(new PartAction(this._map).init(partData, this._player));

        part.start();
        this._parts[type] = part;
        this.dispatchEventWith(EventConstant.PART_CHANGE);
    }
Beispiel #6
0
    public void updateView()
    {
        for (int i = 0, len = ConfigConstant.PART_MODEL_PREFIX.Length; i < len; i++)
        {
            PartAction partData = i >= ConfigConstant.PART_COUNT ? null : this._playerEntity.partGroup.getPart(i);

            string id = null != partData?
                        partData.id.ToString() :
                            ConfigConstant.PART_MODEL_PREFIX[i] + (i == len - 1 ? "000" : this._playerEntity.shipId.Substring(4)); //avatar只有000

            this.createPart(id, i, partData);
        }
    }
Beispiel #7
0
    public PartAction getPart(int type, bool alive = false)
    {
        PartAction part = this._parts[type];

        if (null == part)
        {
            return(null);
        }
        if (alive && part.alived)
        {
            return(part);
        }
        return(part);
    }
        private void ImportFile()
        {
            if (StartImport)
            {
                StartImport         = false;
                btnStartImport.Text = "Start";
                CancellationTokenSource.Cancel();
            }
            else
            {
                if (string.IsNullOrEmpty(FilePath))
                {
                    MessageBox.Show("Please select part configuration file before import");
                    return;
                }

                PartAction action = PartAction.OVERRIDE;
                if (Update.Checked)
                {
                    action = PartAction.UPDATE;
                }
                if (Skip.Checked)
                {
                    action = PartAction.SKIP;
                }

                ExcelPartImport = new ExcelPartImport(FilePath, GenGlobal.CurrentProject);
                ExcelPartImport.InsertPartChanged    += ExcelPartImport_InsertPartChanged;
                ExcelPartImport.ImportDone           += ExcelPartImport_ImportDone;
                ExcelPartImport.ExcelGetPartItemDone += ExcelPartImport_ExcelGetPartItemDone;
                ExcelPartImport.OnExceptionThrown    += ExcelPartImport_OnExceptionThrown;
                ExcelPartImport.ExcelReadDone        += ExcelPartImport_ExcelReadDone;

                int.TryParse(txtTotalImport.Text, out Total);
                txtTotalImport.Text = Total.ToString();
                bool selected = chbSelected.Checked;
                //run an action asynchronously
                StartImport             = true;
                btnStartImport.Text     = "Cancel";
                CancellationTokenSource = new CancellationTokenSource();
                CancellationToken       = CancellationTokenSource.Token;

                ImportTask = Task.Factory.StartNew(() =>
                {
                    ExcelPartImport.ImportPart(Total, selected, action, CancellationToken);
                }, CancellationToken);
            }
        }
Beispiel #9
0
    //————————————————————————————————————单个装备评估——————————————————————————————————————————————————

    ///获得装备当前状态下的预装完成率
    private double getPartCompletePer(PartAction part)
    {
        if (part.alived)
        {
            return(1);
        }
        else if (null == part.preTimeAction)
        {
            return(0);
        }
        else
        {
            double time      = part.preTimeAction.time;
            double totalTime = part.preTimeAction.totalTime;
            return((totalTime - time) / totalTime);
        }
    }
Beispiel #10
0
        private void CallPartView(string commandArgument, List <CallPart> basket, PartAction editMode)
        {
            SiteSession session = SiteSessionFactory.LoadSession(this.Page);
            CallPart    part    = basket.Find(f => f.PartReference.ToString() == commandArgument);

            if (part != null)
            {
                if (session.Data.ContainsKey("part"))
                {
                    session.Data["part"] = orderPartsBLL.Clone(part);
                }
                else
                {
                    session.Data.Add("part", orderPartsBLL.Clone(part));
                }
                SiteSessionFactory.SaveSession(this.Page, session);
                Response.Redirect("~/PartReturn.aspx?from=stock");
            }
        }
Beispiel #11
0
    private void createPart(string id, int type, PartAction partData)
    {
        PartView result = this._gameObjects[type];

        if (result == null)
        {
            result = new PartView((ClientRunTime)this._playerEntity.map);
        }
        if (result.id == id && result.partData == partData)
        {
            return;
        }
        result.init(id, type, partData, this._transform, this._playerEntity, ((Player)this._playerEntity.view).mainScale);
        this._gameObjects[type] = result;
        if (4 == type && null == this._avatarAnimator)
        {
            this._avatarAnimator = result.gameObject.transform.FindChild("go").GetComponent <Animator>();
        }
    }
Beispiel #12
0
 override public void update()
 {
     base.update();
     for (int i = 0, len = this._parts.Count; i < len; i++)
     {
         PartAction part = this._parts[i];
         if (null != part)
         {
             if (part.isFinish)
             {
                 part.checkDead();
                 this.removePart(part.position);
                 this.dispatchEventWith(EventConstant.PART_CHANGE);
             }
             else
             {
                 part.update();
             }
         }
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="max"> Number of part to be added to database</param>
        /// <returns></returns>
        public bool ImportPart(int max, bool selectSeleted, PartAction action, CancellationToken token)
        {
            List <EplPartProperties> EplParts = GetPartProperties(max, selectSeleted);

            foreach (var item in EplParts)
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                if (InsertPart(item, action))
                {
                    InsertPartChanged?.Invoke(item);    // rase an event to main window
                }
            }

            ImportDone?.Invoke(EplParts);

            Dispose();
            return(true);
        }
Beispiel #14
0
 internal PartCommand(SnipPagePart part, PartAction action)
 {
     this._action = action;
     this._part   = part;
 }
Beispiel #15
0
    public void Initialize(PartOrientation orientation)
    {
        item = true;

        creator = GetComponentInParent <CharacterCreator>();
        creator.character.playerStats += partStats;

        partAction = GetComponent <PartAction>();

        anim = GetComponentInChildren <CharacterPartAnimator>();

        GetMeshes();
        SetColors(partColor1, partColor2);

        SetOrientation(orientation);

        switch (partType)
        {
        case PartType.head:
            creator.character.headPoint.parent        = transform;
            creator.character.headPoint.localPosition = specialPoint.localPosition;
            specialPoint.parent = creator.character.headPoint;
            break;

        case PartType.arm:
            if (orientation == PartOrientation.left)
            {
                creator.character.leftArm = this;
            }
            else if (orientation == PartOrientation.right)
            {
                creator.character.rightArm = this;
            }

            Transform holdPoint = (orientation == PartOrientation.right) ? creator.character.rightHandPoint : creator.character.leftHandPoint;
            if (holdPoint)
            {
                holdPoint.parent        = specialPoint;
                holdPoint.localPosition = Vector3.zero;
            }
            break;

        case PartType.body:
            specialPoint.parent = creator.character.headPoint;
            break;

        case PartType.torso:
            transform.parent        = creator.torsoPoint;
            creator.character.torso = this;
            break;

        case PartType.leg:
            transform.parent = creator.torsoPoint;

            if (orientation == PartOrientation.left)
            {
                creator.character.leftLeg = this;
            }
            else if (orientation == PartOrientation.right)
            {
                creator.character.rightLeg = this;
            }

            // foreach (CharacterPartPoint point in creator.character.torso.constraintPoints)
            // {
            //     if (point.pointOrientation == orientation)
            //     {
            //         findPartPoint = point;
            //         break;
            //     }
            // }

            // if (findPartPoint != null)
            // {
            //     // transform.SetParent(findPartPoint.point);
            //     transform.localScale = Vector3.Scale(transform.localScale, findPartPoint.point.localScale);
            //     transform.localPosition = Vector3.right * (findPartPoint.point.localPosition.x) /* + (Vector3.up * transform.position.y) */ + (Vector3.forward * findPartPoint.point.localPosition.z);
            // }

            break;

        case PartType.backAccessory:
            creator.character.backAccessory = this;
            break;
        }
    }
Beispiel #16
0
    //承受伤害,各个部件分摊伤害
    public override void hurt(BulletEntity bullet, double damageRate = 1)
    {
        //如果穿着了装备,先判定命中位置
        int damage = (int)(bullet.getDamage(this) * damageRate);
        //伤害加深。
        List <Buff> buffs = this.getBuffs(ConfigConstant.BUFF_HURT_SHALLOW);

        //TODO:如果都是乘以我就不用排序了!
        for (int i = 0, len = buffs.Count; i < len; i++)
        {
            damage = Mathf.CeilToInt(Convert.ToSingle(LogicOperation.operation(Convert.ToSingle(damage), buffs[i].value, buffs[i].operation)));
        }

        //对玩家造成了伤害,子弹的主人奖励积分
        bullet.ownerPlayer.changeScore(Mathf.CeilToInt(Convert.ToSingle(ConfigConstant.SCORE_DAMAGE * damage)));
        //护盾
        damage = this.hurtShield(damage);
        //忽略体积
        if (Utils.equal(bullet.data, "ignoreBear", 1))
        {
            damage = Mathf.CeilToInt(Convert.ToSingle(damage * (1 - this.getProperty(ConfigConstant.PROPERTY_DEF_RATE))));
        }
        else
        {
            damage = Mathf.CeilToInt(Convert.ToSingle(damage * (1 - this.getProperty(ConfigConstant.PROPERTY_DEF_RATE)) * this.getProperty(ConfigConstant.PROPERTY_BEAR_RATE)));
            //如果穿着了装备,先判定命中位置
            if (this.partGroup.hasPart)
            {
                Vector2D deltaP = bullet.getHitPos(this);
                //转化相对角度
                deltaP.angle -= this.angle;
                //依次判定相对命中点 距离4个装备参考点是否算命中
                //			double distance;
                int        bangRadius = (int)(bullet.radiusMax + ConfigConstant.SHIP_RADIUS * 0.5f);
                List <int> hitParts   = new List <int>();
                if (deltaP.dist(partHeadOffset) <= bangRadius)
                {
                    //前部件被命中
                    hitParts.Add(0);
                }
                if (deltaP.dist(partWingOffsetL) <= bangRadius || deltaP.dist(partWingOffsetR) <= bangRadius)
                {
                    //中部件被命中
                    hitParts.Add(1);
                }
                if (deltaP.dist(partTailOffset) <= bangRadius)
                {
                    //后部件被命中
                    hitParts.Add(2);
                }
                //根据被命中的部件个数,每个部件分摊伤害
                int hitCount = hitParts.Count;
                if (hitCount > 0)
                {
                    int tempDamage;
                    int damagePerPart = damage / hitCount;
                    int i;
                    for (i = 0; i < hitCount; i++)
                    {
                        PartAction part = this.partGroup.getPart(hitParts[i], true);
                        if (part != null)
                        {
                            //装备部件分担伤害
                            tempDamage = Mathf.CeilToInt(Convert.ToSingle(damagePerPart * part.hpRate));
                            part.beHit(tempDamage);
                            damage -= tempDamage;
                        }
                    }
                }
            }
        }

        this.changeHp(-damage);
    }
Beispiel #17
0
 ///获得装备当前状态下的血量存量
 private double getPartHpPer(PartAction part)
 {
     return((double)part.hp / part.hpMax);
 }
Beispiel #18
0
 //获得装备当前状态下的总体状态比率
 private double getPartScale(PartAction part)
 {
     return(part.alived ? Math.Pow(this.getPartHpPer(part), 0.1) : this.getPartCompletePer(part) * 0.7);
 }
Beispiel #19
0
    public void init(string id, int type, PartAction partData, Transform parent, ClientPlayerEntity playerEntity, float scoreScale)
    {
        this.type          = type;
        this._playerEntity = playerEntity;
        this._map          = (ClientRunTime)this._playerEntity.map;
        //不同id 更换
        if (this.id != id)
        {
            this.id = id;
            if (null != this.gameObject)
            {
                LeanTween.cancel(this.gameObject);
                GameObject.Destroy(this.gameObject);
            }
            this.gameObject = ResFactory.getShip(id);
            //翅膀
            if (this.type == 1)
            {
                GameObject goLeft = ResFactory.createObject <GameObject>(this.gameObject);
                goLeft.name = "left";
                //右
                GameObject goRight = ResFactory.createObject <GameObject>(this.gameObject);
                goRight.transform.localScale = new Vector3(1, -1, 1);
                goRight.name = "right";

                this.gameObject = new GameObject();
                goLeft.transform.SetParent(this.gameObject.transform, false);
                goRight.transform.SetParent(this.gameObject.transform, false);
            }
            else
            {
                this.gameObject = ResFactory.createObject <GameObject>(this.gameObject);
            }
            this.gameObject.name = id;

            this.gameObject.transform.SetParent(parent, false);
            if (type == 5 - 1)
            {
                this.gameObject.transform.localPosition = new Vector3(0, 0, 1);
            }
            else
            {
                this.gameObject.transform.localPosition = new Vector3();
            }
            this._material = ViewUtils.getMaterial(this.gameObject, ViewConstant.SHIP_SHADER_NAME);
            ViewUtils.changeColor(this._material, (Dictionary <string, object>)ViewConstant.shipConfig[this._playerEntity.shipColorId]);
        }

        if (partData != this.partData)
        {
            this.resetPart(scoreScale, scoreScale, scoreScale);
        }
        //两个装备不等 直接重置装备。可以是同id替换


        if (null != partData && this.partData != partData)
        {
            //如果装备立刻启用的话 在一进入可能瞬间装备就生效了!
            if (partData.alived)
            {
                this.partStartHandler(null);
            }
            else
            {
                this._color          = ViewUtils.cloneColor(ViewConstant.SHADER_COLOR_WARM);
                this._material.color = this._color;
                ViewUtils.setEnable(this.gameObject, false);
                /*************************启用用装备******************************/
                partData.addListener(EventConstant.ALIVED, partStartHandler);
            }

            /*************************受伤闪红******************************/
            partData.addListener(EventConstant.HURT, (e) => {
                ViewUtils.colorInOutMaterial(this.gameObject, this._material, ViewConstant.SHADER_COLOR_RED, ViewConstant.SHADER_COLOR_STANDARD, 0.05f, 0.3f);
            });
        }
        this.partData = partData;
    }
Beispiel #20
0
    ///传入需要评估的范畴和内容,返回评估结果
    private double[] getPartTypeMark(PartAction part, int aspectType, int valueType)
    {
        MarkVO mark = MarkVO.getMarkByPartId(part.id);

        return(ArrayUtils.multiplyArrayValue(mark.getTypeMark(aspectType, valueType), this.getPartScale(part)));
    }
        /// <summary>
        ///
        /// </summary>
        /// <param name="Project"></param>
        /// <param name="eplPartProperties"></param>
        /// <returns>true if successed</returns>
        public bool InsertPart(EplPartProperties eplPartProperties, PartAction action)
        {
            try
            {
                MDPart part = GetPart(eplPartProperties.PartNumber);

                if (part != null)
                {
                    switch (action)
                    {
                    case PartAction.OVERRIDE:
                        PartsDataBase.RemovePart(part);
                        part = AddPart(eplPartProperties.PartNumber);
                        break;

                    case PartAction.UPDATE:
                        break;

                    case PartAction.SKIP:
                        return(true);
                    }
                }
                else
                {
                    part = AddPart(eplPartProperties.PartNumber);
                }

                if (part == null)
                {
                    Logger.WriteLine("Add new part failed.");
                    return(false);
                }

                part.GenericProductGroup = MDPartsDatabaseItem.Enums.ProductTopGroup.Electric;
                part.ProductGroup        = MDPartsDatabaseItem.Enums.ProductGroup.Common;
                part.ProductSubGroup     = MDPartsDatabaseItem.Enums.ProductSubGroup.Common;

                part.Properties.ARTICLE_SUPPLIER          = eplPartProperties.Supplier;
                part.Properties.ARTICLE_NOTE              = eplPartProperties.Description;
                part.Properties.ARTICLE_MANUFACTURER      = eplPartProperties.Manufacturer;
                part.Properties.ARTICLE_ORDERNR           = eplPartProperties.OrderNumber;
                part.Properties.ARTICLE_QUANTITYUNIT      = eplPartProperties.Unit;
                part.Properties.ARTICLE_PACKAGINGQUANTITY = eplPartProperties.Quantity;
                part.Properties.ARTICLE_MACRO             = eplPartProperties.Macro;
                part.Properties.ARTICLE_CHARACTERISTICS   = eplPartProperties.Characteristic;
                part.Properties.ARTICLE_PACKAGINGPRICE_1  = eplPartProperties.Price;
                part.Properties.ARTICLE_REPORT_SYMBOL[1]  = eplPartProperties.Symbol;
                part.Properties.ARTICLE_GROUPNUMBER       = eplPartProperties.PartGroup;

                part.Properties.ARTICLE_VOLTAGE                = eplPartProperties.Voltage;
                part.Properties.ARTICLE_VOLTAGETYPE            = eplPartProperties.VoltageType;
                part.Properties.ARTICLE_ELECTRICALCURRENT      = eplPartProperties.Current;
                part.Properties.ARTICLE_TRIGGERCURRENT         = eplPartProperties.TrippingCurrent;
                part.Properties.ARTICLE_CONNECTIONCROSSSECTION = eplPartProperties.ConnectionPointCrossSection;
                part.Properties.ARTICLE_ELECTRICALPOWER        = eplPartProperties.SwitchingCapacity;
                part.Properties.ARTICLE_POWERDISSIPATION       = eplPartProperties.MaxPowerDissipation;

                if (eplPartProperties.PartFreeProperties != null)
                {
                    for (int i = 0; i < eplPartProperties.PartFreeProperties.Count; i++)
                    {
                        part.Properties.ARTICLE_FREE_DATA_DESCRIPTION[i + 1] = eplPartProperties.PartFreeProperties[i].Description;
                        part.Properties.ARTICLE_FREE_DATA_VALUE[i + 1]       = eplPartProperties.PartFreeProperties[i].Value;
                        part.Properties.ARTICLE_FREE_DATA_UNIT[i + 1]        = eplPartProperties.PartFreeProperties[i].Unit;
                    }
                }

                Logger.WriteLine($"Create part: {eplPartProperties.PartNumber} successfully.");
                return(true);
            }
            catch (Exception e)
            {
                OnExceptionThrown?.Invoke($"Insert Part {eplPartProperties.PartNumber} error.");
                Logger.WriteLine("InsertPart error.", e);
                return(false);
            }
        }
Beispiel #22
0
        public void AddExecSetPropertyDesignerCommand <T>(SnipPageDesigner designer, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod, PartAction action)
        {
            SetPropertyDesignerCommand <T> cmd = new SetPropertyDesignerCommand <T>(designer, oldValue, newValue, setCoreMethod, action);

            cmd.Execute();
            AddCommand(cmd);
            Designer.IsModified = true;
        }
Beispiel #23
0
 public SetPropertyPartCommand(SnipPagePart part, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod, PartAction action)
     : base(part, action)
 {
     _oldValue           = oldValue;
     _newValue           = newValue;
     this._setCoreMethod = setCoreMethod;
 }
Beispiel #24
0
    ///传入需要评估的内容,返回评估结果
    private double getPartMark(PartAction part, int valueType)
    {
        MarkVO mark = MarkVO.getMarkByPartId(part.id);

        return(mark.getMark(valueType) * this.getPartScale(part));
    }