예제 #1
0
        public async Task <string> GetUnitNodeRequest()
        {
            var url      = Route.SERVER_PATH + Route.API_PATH + Route.URLDictionary["api.get_unit_node"];
            var request  = new Autin.Services.HttpRequest(); // [email protected], Mba287xd!
            var response = await request.PostRequest(url,
                                                     new Dictionary <string, string>() {
                { "user_id", $"{SystemManager.Instance.CurrentUser.Id}" },
                { "client_id", $"{SystemManager.Instance.CurrentUser.ClientId}" },
                { "case_id", $"{SystemManager.Instance.CurrentCaseId}" },
                { "client_token", $"{SystemManager.Instance.CurrentUser.ClientToken}" },
                { "settlement_date", $"{SystemManager.Instance.CurrentSettlementDate}" }
            });

            if (response.Contains("Error"))
            {
                return("fails");
            }
            try
            {
                if (SystemManager.Instance.CurrentUnitList == null)
                {
                    SystemManager.Instance.CurrentUnitList = new Unit();
                }
                SystemManager.Instance.CurrentUnitList.UnitNode = UnitNode.FromJson(response);
                Console.WriteLine("get UnitParam list successfully!");
                return("success");
            }
            catch
            {
                Console.WriteLine("get UnitParam list fails!");
                return("fails");
            }
        }
예제 #2
0
    public SyncUnitInfo(Unit unit)
    {
        UnitNode node = unit.Node;

        baseInfo.model = unit.Model;
        baseInfo.name  = unit.Name;
        baseInfo.maxHp = unit.MaxHpBase;
        AttackAct attack = unit.AttackSkill as AttackAct;

        if (attack != null)
        {
            baseInfo.attackSkill            = new AttackInfo();
            baseInfo.attackSkill.cd         = attack.coolDownBase;
            baseInfo.attackSkill.type       = AttackValue.TypeToName(attack.AttackType);
            baseInfo.attackSkill.value      = attack.AttackValueBase;
            baseInfo.attackSkill.range      = attack.CastRange;
            baseInfo.attackSkill.horizontal = attack.CastHorizontal;
            List <int> castAnimations = attack.castAnimations;
            baseInfo.attackSkill.animations = new string[castAnimations.Count];
            for (int i = 0; i < castAnimations.Count; ++i)
            {
                baseInfo.attackSkill.animations[i] = ModelNode.IdToName(castAnimations[i]);
            }
            baseInfo.attackSkill.projectile = attack.ProjectileTemplate.Model;
        }

        position           = node.position;
        flippedX           = node.flippedX;
        hp                 = unit.Hp;
        force              = unit.force.Force;
        baseInfo.move      = unit.MoveSpeedBase;
        baseInfo.revivable = unit.Revivable;
        baseInfo.isfixed   = unit.Fixed;
    }
예제 #3
0
        public override void VisitUnitNode(UnitNode node)
        {
            AddLineCodeFormat("namespace {0}", node.UnitNameNode.Text);
            AddFullLineCode("{");
            Indent();
            AddFullLineCode("using System;");
            AddFullLineCode("using System.Collections.Generic;");
            AddLineCode("");
            IEnumerable <UsedUnitNode> uses = new UsedUnitNode[0];

            if (node.InterfaceSectionNode.UsesClauseNode != null)
            {
                uses = uses.Union(node.InterfaceSectionNode.UsesClauseNode.UnitListNode.Items.Select(x => x.ItemNode));
            }
            if (node.ImplementationSectionNode.UsesClauseNode != null)
            {
                uses = uses.Union(node.ImplementationSectionNode.UsesClauseNode.UnitListNode.Items.Select(x => x.ItemNode));
            }

            foreach (var use in uses.Select(x => x.FileNameNode.Text).Distinct())
            {
                AddFullLineCodeFormat("using {0};", use);
            }

            Visit(node.InterfaceSectionNode);
            Visit(node.ImplementationSectionNode);
            Visit(node.InitSectionNode);
            Visit(node.DotNode);

            UnIndent();
            AddFullLineCode("}");
        }
예제 #4
0
    public UnitGroup(World pWorld, Vector2 roPos, float fRadius, int iMaxCount = CONST_COUNT_UNLIMITED, MatchFunction match = null, UnitForce force = null)
    {
        if (fRadius < float.Epsilon)
        {
            return;
        }

        var units = pWorld.Units;

        foreach (var kv in units)
        {
            Unit u = kv.Key;
            if (u.Ghost)
            {
                continue;
            }

            UnitNode d = u.Node;
            if (m_units.Count >= iMaxCount)
            {
                return;
            }
            if (Vector2.Distance(d.position, roPos) - d.HalfOfWidth < fRadius && (match == null || (match(u, force))))
            {
                m_units.Add(u);
            }
        }
    }
예제 #5
0
 public LinkAnimate(cca.Animation animation, Animate.Function onSpecial, UnitNode from, UnitNode to)
     : base(animation, onSpecial)
 {
     m_fromToType = Projectile.FromToType.kUnitToUnit;
     m_from.Set(from.GetComponent <Unit>());
     m_to.Set(to.GetComponent <Unit>());
 }
예제 #6
0
 public SystemNode(int entityID, string NAME, string JCATS_SystemCharName, UnitNode superUnit)
 {
     this.EntityID             = entityID;
     this.NAME                 = NAME;
     this.JCATS_SystemCharName = JCATS_SystemCharName;
     this.SuperUnit            = superUnit;
 }
예제 #7
0
    public static Unit getNearestUnitInRange(World pWorld, Vector2 roPos, float fRadius, MatchFunction match = null, UnitForce force = null)
    {
        Unit  target  = null;
        float fMinDis = float.MaxValue;
        float fDis;

        var units = pWorld.Units;

        foreach (var kv in units)
        {
            Unit u = kv.Key;
            if (u.Ghost)
            {
                continue;
            }

            UnitNode d = u.Node;
            if ((fDis = Vector2.Distance(d.position, roPos) - d.HalfOfWidth) < fRadius && fMinDis > fDis && (match == null || (match(u, force))))
            {
                target  = u;
                fMinDis = fDis;
            }
        }

        return(target);
    }
예제 #8
0
    public void AssignModelToUnitNode(string modelPath, UnitNode node)
    {
        var modelInfo = GetModelInfo(modelPath) as UnitModelInfo;

        AssignModelToNode(modelPath, node, modelInfo);
        node.SetGeometry((float)modelInfo.half.x, (float)modelInfo.half.y, new Vector2((float)modelInfo.fire.x, (float)modelInfo.fire.y));
    }
예제 #9
0
    protected void fixTargetPosition()
    {
        UnitNode from = m_from.Node;
        UnitNode to   = m_to.Node;

        if (from == null || to == null)
        {
            return;
        }

        ProjectileNode target = _target as ProjectileNode;

        m_fromPos = from.position;

        float fFromOffsetX = 0.0f;
        float fFromHeight  = 0.0f;

        if (m_fireFrom)
        {
            bool  useFireOffset = (_target as ProjectileNode).Projectile.UseFireOffset;
            float offsetX       = useFireOffset ? from.FireOffset.x : from.HalfOfWidth;
            float offsetY       = useFireOffset ? from.FireOffset.y : from.HalfOfHeight;
            bool  bFlipX        = m_fromPos.x > m_toPos.x;
            fFromOffsetX = (bFlipX ? -offsetX : offsetX);
            fFromHeight  = from.height + offsetY;
        }
        else
        {
            fFromHeight = from.height + from.HalfOfHeight;
        }

        m_fromPos.x += fFromOffsetX;
        m_fromPos.y += fFromHeight;

        m_toPos = to.position;
        float fToHeight = to.height + to.HalfOfHeight;

        m_toPos.y += fToHeight;

        //RendererNode rendererTarget = _target as RendererNode;
        //rendererTarget.height = (fFromHeight + fToHeight) / 2;

        //World.Main.dbgPos[0].transform.position = new Vector3(m_fromPos.x, m_fromPos.y, -200);
        //World.Main.dbgPos[1].transform.position = new Vector3(m_toPos.x, m_toPos.y, -200);

        Vector2 delta = m_toPos - m_fromPos;
        float   fR    = Utils.GetAngle(delta);

        float fScale = Mathf.Sqrt(delta.x * delta.x + delta.y * delta.y) / target.size.x;

        target.position = new Vector2((m_fromPos.x + m_toPos.x) / 2, (m_fromPos.y + m_toPos.y) / 2);
        //World.Main.dbgPos[2].transform.position = new Vector3(_target.gameObject.transform.position.x, _target.gameObject.transform.position.y, -200);
        //World.Main.dbgPos[2].transform.position = new Vector3(target.position.x, target.position.y, -200);
        target.rotation = fR;
        Vector2 scale = target.scale;

        scale.x      = fScale;
        target.scale = scale;
    }
예제 #10
0
    public virtual void DoMoveToUnit(UnitNode pToUnit, bool bFixRotation, float fMaxHeightDelta, float duration, Function onFinished)
    {
        ActionInterval act = new MoveToNode(duration, pToUnit, true, fMaxHeightDelta);

        act     = new Sequence(act, new CallFunc(onFinished));
        act.tag = kActionMoveTo;
        runAction(act);
    }
예제 #11
0
 public SyncDoAnimate(UnitNode node, int id, int loop, float speed, bool stopAllFirst)
     : base(node)
 {
     this.id           = id;
     this.loop         = loop;
     this.speed        = speed;
     this.stopAllFirst = stopAllFirst;
 }
예제 #12
0
        public string Convert(string delphiCode)
        {
            UnitNode unitNode = CreateAstNodeTree(delphiCode);

            CodeCompileUnit compileUnit = ConvertToCodeDom(unitNode);

            return(GenerateCSharp(compileUnit));
        }
예제 #13
0
 public SyncDoMoveTo(UnitNode node, Vector2 pos, float duration, float speed)
     : base(node)
 {
     posX          = pos.x;
     posY          = pos.y;
     this.duration = duration;
     this.speed    = speed;
 }
예제 #14
0
    public override void Initialise(Vector3 createPos, CanvasCreator newParent)
    {
        base.Initialise(createPos, newParent);

        unitNode         = new GameObject().AddComponent <UnitNode> ();
        unitNode.country = country;
        unitNode.Initialise(gameObject.transform.position, newParent);
        EstablishLink(unitNode);
    }
예제 #15
0
 public virtual T Visit(UnitNode node)
 {
     Visit((TranslationUnit)node);
     traverse(node.@interface);
     traverse(node.implementation);
     traverse(node.initialization);
     traverse(node.finalization);
     return(DefaultReturnValue());
 }
예제 #16
0
 public override bool Visit(UnitNode node)
 {
     declEnv.EnterNextContext();
     traverse(node.@interface);
     traverse(node.implementation);
     traverse(node.initialization);
     traverse(node.finalization);
     return(true);
 }
예제 #17
0
 public override bool Visit(UnitNode node)
 {
     Visit((TranslationUnit)node);
     TraversePrint(node.@interface);
     TraversePrint(node.implementation);
     TraversePrint(node.initialization);
     TraversePrint(node.finalization);
     return(true);
 }
예제 #18
0
        public override IDisposable Subscribe(IObserver <Any> observer)
        {
            var reducer               = new PagePopReducer();
            var valueNode             = new UnitNode(this.Parent);
            var stateActionWriterNode = new StateActionWriterNode(
                valueNode, "page", StoreHolder, reducer
                );

            return(stateActionWriterNode.Subscribe(observer));
        }
예제 #19
0
    public MoveToNode(float duration, UnitNode node, bool fixRotation = true, float maxHeightDelta = 0.0f)
        : base(duration)
    {
        _eToType = kTypeUnit;
        _unit.Set(node.GetComponent <Unit>());

        _bFixRotation    = fixRotation;
        _fMaxHeightDelta = maxHeightDelta;
        _fMinSpeed       = 0;
    }
예제 #20
0
 public virtual void VisitUnitNode(UnitNode node)
 {
     Visit(node.UnitKeywordNode);
     Visit(node.UnitNameNode);
     Visit(node.PortabilityDirectiveListNode);
     Visit(node.SemicolonNode);
     Visit(node.InterfaceSectionNode);
     Visit(node.ImplementationSectionNode);
     Visit(node.InitSectionNode);
     Visit(node.DotNode);
 }
예제 #21
0
파일: UnitAI.cs 프로젝트: t5w0rd/uHeroes
    public virtual void OnUnitTick(Unit unit, float dt)
    {
        if (unit.Suspended || unit.IsDoingOr(Unit.kDoingObstinate))
        {
            // 如果正在固执做事或正在施法
            return;
        }

        if (unit.IsDoingOr(Unit.kDoingCasting) && !unit.IsDoingOr(Unit.kDoingMoving))
        {
            // 原地施法
            return;
        }

        UnitNode d = unit.Node;

        ActiveSkill atk = unit.AttackSkill;

        if (atk == null)
        {
            return;
        }

        // 追击目标仍在仇恨区内就继续追击
        if (unit.CastActiveSkill == atk && unit.CastTarget.TargetType == CommandTarget.Type.kUnitTarget)
        {
            Unit tt = unit.CastTarget.TargetUnit;
            if (tt != null)
            {
                UnitNode ttd = tt.Node;
                if (ttd != null && unit.IsDoingAnd(Unit.kDoingCasting | Unit.kDoingMoving) && Vector2.Distance(d.position, ttd.position) < unit.HostilityRange)
                {
                    // 正在追击施法,距离在仇恨范围内
                    return;
                }
            }
        }

        Unit t = UnitGroup.getNearestUnitInRange(unit.World, d.position, unit.HostilityRange, UnitGroup.MatchFunctionLivingEnemy, unit.force);

        if (t == null || t.isDead)
        {
            // 搜不到仇恨区内的目标,有没有必要设置为doNothing?
            return;
        }

        if (unit.CastActiveSkill != atk || unit.CastTarget.TargetUnit != t)
        {
            //Debug.LogFormat("{0} want to attack {1}.", unit.Name, t.Name);
            unit.CommandCastSpell(new CommandTarget(t), atk, false);
        }
    }
예제 #22
0
    protected void UpdateAttackActionSpeed()
    {
        Unit o = m_owner;

        Debug.Assert(o != null);
        o.UpdateSkillCD(this);
        UnitNode d = o.Node;

        if (o.CastActiveSkill == o.AttackSkill)
        {
            d.SetActionSpeed(o.CastActionId, coolDownSpeedCoeff);
        }
    }
예제 #23
0
        public void AddParsedFile(string fileName, string fileSource, AstNode parseTree)
        {
            NamedContent <AstNode> namedParseTree = new NamedContent <AstNode>(fileName, parseTree);
            UnitNode unit = parseTree as UnitNode;

            if (unit != null)
            {
                AddParsedFileToCollection(_units, fileName, fileSource, unit);
            }
            else
            {
                AddParsedFileToCollection(_projects, fileName, fileSource, parseTree);
            }
        }
예제 #24
0
        private static UnitNode CreateAstNodeTree(string delphiCode)
        {
#if NEVER
            // Parse without filtering out comment tokens...
            Lexer  lexer  = new Lexer(delphiCode, "input");
            Parser parser = Parser.FromTokens(lexer.Tokens);
#endif
            Parser parser = Parser.FromText(delphiCode, "input", CompilerDefines.CreateStandard(),
                                            new MemoryFileLoader());

            AstNode tree = parser.ParseRule(RuleType.Unit);
            //var Text = tree.Inspect();

            UnitNode unitNode = (UnitNode)tree;
            return(unitNode);
        }
예제 #25
0
    public override void OnUnitAttackTarget(AttackData pAttack, Unit pTarget)
    {
        Unit o = m_owner;

        if (!pTarget || o == null)
        {
            return;
        }

        UnitNode td = pTarget.Node;
        float    fDis;
        World    w     = o.World;
        var      units = w.Units;

        foreach (Unit pUnit in units.Keys)
        {
            if (pUnit == pTarget)
            {
                continue;
            }

            UnitNode pDraw = pUnit.Node;
            if (pUnit.Ghost)
            {
                continue;
            }

            fDis = Mathf.Max(0.0f, Vector2.Distance(pDraw.position, td.position) - pDraw.HalfOfWidth);
            if (fDis <= m_fFarRange && o.force.CanEffect(pUnit.force, m_effectiveTypeFlags))
            {
                AttackData  ad = pAttack.Clone();
                AttackValue av = ad.attackValue;

                if (fDis <= m_fNearRange)
                {
                    av.x = m_oExNearDamage.GetValue(av.v);
                }
                else
                {
                    av.x = m_oExFarDamage.GetValue(av.v);
                }

                pUnit.Damaged(ad, o, m_dwTriggerMask);
            }
        }
    }
예제 #26
0
    public virtual void DoLinkUnitToUnit(UnitNode from, UnitNode to, int id, Function onSpecial, int loop, Function onFinished)
    {
        ActionInterval act;

        cca.Animation ani;
        if (!m_animations.TryGetValue(id, out ani))
        {
            if (id == kActionDie)
            {
                act = new FadeOut(0.1f);
            }
            else
            {
                act = new DelayTime(0.2f);
            }
            if (onSpecial != null)
            {
                act = new Sequence(act, new CallFunc(onSpecial));
            }
        }
        else
        {
            visible = false;
            act     = new LinkAnimate(ani, delegate(int index, ref object data) {
                if (onSpecial != null)
                {
                    onSpecial();
                }
            }, from, to);
        }

        if (loop == CONST_LOOP_FOREVER)
        {
            act = new RepeatForever(act);
        }
        else
        {
            act = new Sequence(new Repeat(act, (uint)loop), new CallFunc(onFinished));
        }

        //m_node.stopActionByTag(id);
        act.tag = id;
        runAction(act);
    }
예제 #27
0
        public override bool Visit(UnitNode node)
        {
            Visit((TranslationUnit)node);
            traverse(node.@interface);
            traverse(node.implementation);

            if (node.initialization != null)
            {
                outputCode(node.name + "_init()", false, true);
                traverse(node.initialization);
            }

            if (node.finalization != null)
            {
                outputCode(node.name + "_finish()", false, true);
                traverse(node.finalization);
            }
            return(true);
        }
    // called on start
    private void CloneEntities_Rec(UnitNode unit, Material force)
    {
        Dictionary <string, SystemType> systemDictionary = this.entityTypes.SystemDictionary;

        foreach (var m in unit.Systems)
        {
            GameObject clone = new GameObject();
            clone.name = "" + m.EntityID;
            GameObject model;

            if (systemDictionary.ContainsKey(m.JCATS_SystemCharName))
            {
                model = Instantiate(Resources.Load(systemDictionary[m.JCATS_SystemCharName].ModelFile) as GameObject);
            }
            else
            {
                model = Instantiate(Resources.Load("Models/unknown") as GameObject);
                Debug.Log("UNDEFINED IN XML: " + m.JCATS_SystemCharName);
            }

            model.transform.parent = clone.transform;

            foreach (Transform child in model.transform)
            {
                child.GetComponent <Renderer>().material             = force;
                child.GetComponent <Renderer>().material.mainTexture = militaryTexture;
            }

            clone.transform.position = new Vector3(0, UnityEngine.Random.Range(-1000000, -10000));
        }

        if (unit.Subunits.Count < 0)
        {
            return;
        }

        foreach (var subunit in unit.Subunits)
        {
            CloneEntities_Rec(subunit, force);
        }
    }
    // called only on start
    private void Treeview_FillWithItems_Rec(Treeview_DataModel father, UnitNode unit, string origin)
    {
        Treeview_DataModel son = new Treeview_DataModel {
            Text = unit.NAME, EntityID = unit.JCATS_ID, IsUnit = true, Health = 100, Father = father
        };

        Dictionary <string, UnitType> unitDictionary = this.entityTypes.UnitDictionary;

        if (unitDictionary.ContainsKey(XmlReader.CutString(unit.NAME) + origin))
        {
            WWW www = new WWW("file:///" + Application.dataPath + "/" + unitDictionary[XmlReader.CutString(unit.NAME) + origin].NatoSymbolFile);
            StartCoroutine(LoadTextureViaWWW(www, son));
        }
        else
        {
            WWW www = new WWW("file:///" + Application.dataPath + "/" + unitDictionary["UNKNOWN" + origin].NatoSymbolFile);
            StartCoroutine(LoadTextureViaWWW(www, son));
        }

        foreach (var s in unit.Systems)
        {
            son.Children.Add(new Treeview_DataModel {
                Text = s.JCATS_SystemCharName, EntityID = s.EntityID, IsUnit = false, Health = 0, Father = son
            });                                                                                                                                          // || m.NAME
        }

        father.Children.Add(son);

        if (unit.Subunits.Count < 0)
        {
            return;
        }

        foreach (var subunit in unit.Subunits)
        {
            Treeview_FillWithItems_Rec(son, subunit, origin);
        }

        // TODO is this correct; I moved up
        //father.Children.Add(son);
    }
예제 #30
0
    /// <summary>
    /// need fromUnit,toUnit
    /// </summary>
    void FireLink()
    {
        Unit     u = m_fromUnit;
        UnitNode d = u.Node;

        Unit     t  = m_toUnit;
        UnitNode td = t.Node;

        Debug.Assert(u != null && t != null && d != null && td != null);

        m_fromPos = d.position;
        m_toPos   = td.position;
        m_node.stopAllActions();

        cca.Function onEffect = null;
        if (HasEffectFlag(kEffectOnDying))
        {
            onEffect = OnEffect;
        }
        m_node.DoLinkUnitToUnit(d, td, ModelNode.kActionDie, onEffect, 1, OnDyingDone);
    }
예제 #31
0
    public override void Initialise(Vector3 createPos, CanvasCreator newParent)
    {
        base.Initialise (createPos, newParent);

        unitNode = new GameObject ().AddComponent<UnitNode> ();
        unitNode.country = country;
        unitNode.Initialise (gameObject.transform.position, newParent);
        EstablishLink (unitNode);
    }
예제 #32
0
 public virtual void VisitUnitNode(UnitNode node)
 {
     Visit(node.UnitKeywordNode);
     Visit(node.UnitNameNode);
     Visit(node.PortabilityDirectiveListNode);
     Visit(node.SemicolonNode);
     Visit(node.InterfaceSectionNode);
     Visit(node.ImplementationSectionNode);
     Visit(node.InitSectionNode);
     Visit(node.DotNode);
 }