Exemple #1
0
    public double CalculateValue(condition c, long pn)
    {
        // TODO: Look elsewhere to find market value for the item USING THE "pn"
        // e.g. float inVal = searchDBValue(pn);
        double inVal = 10.20d;

        // If the item is composition of other items then add each of their values
        // to the base values of the item
        if (_Components.Length > 0)
        {
            foreach (Item i in _Components)
            {
                inVal += i._Value;
            }
        }

        // Ensuring value of item found using pn is round to 2dp
        double outVal = Math.Round(inVal, 2);

        // Calculating condition multiplier for value of item
        double condMulti = CalculateCondMulti(c);

        // Finally multiply the outVal * condMulti to arrive at final return value
        return(outVal * condMulti);
    }
Exemple #2
0
 /// <summary>
 /// Utility method used to clean the state of a chunk. It has the signature of an event method
 /// because it is passed to a timer class.
 /// </summary>
 /// <param name="source">ND</param>
 /// <param name="e">ND</param>
 private void cleaner(object source, EventArgs e)
 {
     if (this.actualCondition == condition.DIRTY)
     {
         this.actualCondition = condition.CLEAN;
     }
 }
    public static GameObject FindChildInCondition(this GameObject _this, condition cond)
    {
        if (_this == null)
        {
            return(null);
        }

        Transform transform = _this.GetComponent <Transform>();

        foreach (Transform trans in transform)
        {
            if (cond(trans.gameObject))
            {
                return(trans.gameObject);
            }
            else
            {
                GameObject obj = trans.gameObject.FindChildInCondition(cond);
                if (obj)
                {
                    return(obj);
                }
            }
        }

        return(null);
    }
Exemple #4
0
    public void MoveTo(Vector3 targetPos, bool topPriority = false)
    {
        ResetValues();
        ThrowUniversalEvent("EventMovementToTheTargetRequested");

        if (!spaceManagerInstance.isPrimaryProcessingCompleted)
        {
            throw new GraphNotReadyException();
        }

        if (Vector3.Distance(thisTransformInstance.position, targetPos) < SpaceGraph.cellMinSideLength)
        {
            foundPath = new List <Vector3> {
                thisTransformInstance.position, targetPos
            };
            finalPath   = new List <Vector3>(foundPath);
            curCond     = WaitingForWayProcessing;
            targetCoord = targetPos;
            ThrowUniversalEvent("EventPathWasFound");
            ThrowUniversalEvent("EventProcessingStarted");
            ProcessPath(foundPath);
            return;
        }

        ThrowUniversalEvent("EventPathfindingRequested");
        curCond     = WaitingForPursuersQueue;
        curPos      = thisTransformInstance.position;
        targetCoord = targetPos;
        QueueUpForPathfinding(topPriority);
    }
Exemple #5
0
        public KeyValuePair <condition, narrative> readNextScene()
        {
            if (file.Peek() == -1)
            {
                throw new System.IO.IOException("Slumscript syntax error in scene count");
            }
            string curr = file.ReadLine();

            curr.Trim();
            while (String.Compare(curr, "") == 0)
            {
                curr = file.ReadLine();
            }
            if (String.Compare(curr, "BEGIN") != 0)
            {
                throw(new System.IO.IOException("Slumscript syntax error in scene " + currentScene));
            }
            condition c = parseConditition();
            // Read lines until end
            List <string> lines = new List <string>();

            curr = file.ReadLine();
            curr.Trim();
            while (String.Compare(curr, "END") != 0)
            {
                lines.Add(curr);
                curr = file.ReadLine();
            }

            return(new KeyValuePair <condition, narrative>(c, parseScene(lines)));
        }
Exemple #6
0
    /// <summary>
    /// Places pursuer to the WaitingForRequest state.
    /// Resets all non-public & internal variables, destroys line visualization, if it's existing.
    /// Stops all async tasks.
    /// </summary>
    void ResetValues()
    {
        LeavePathfindingQueue();
        if (trajectoryVisualLine != null)
        {
            Destroy(trajectoryVisualLine);
            trajectoryVisualLine = null;
        }

        cTSInstance.Cancel();
        cTSInstance = new CancellationTokenSource();
        curCond     = WaitingForRequest;
        finalPath.Clear();
        foundPath.Clear();
        refinedPath.Clear();
        totalLength = 0;
        offset      = 0;
        actionsQueue.Clear();
        isRefiningInProgress = false;
        prePointI            = 0;
        if (spaceManagerInstance.gridDetailLevelsCount <= pathfindingLevel)
        {
            pathfindingLevel = spaceManagerInstance.gridDetailLevelsCount - 1;
        }
    }
        /// <summary>
        /// Constructor... yeah
        /// </summary>
        public Objective(int id)
        {
            nextObjectives = new List<int>();

            state = condition.initialized;

            this.id = id;
        }
Exemple #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            condition condition = db.conditions.Find(id);

            db.conditions.Remove(condition);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Add the condition to the conditions part.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="cxpId"></param>
        /// <param name="strXPath"></param>
        /// <param name="prefixMappings"></param>
        public condition setup(xpathsXpath xpath)
        {
            condition result = null;

            //////////////////////////
            // Second, create and add the condition

            // If the Condition is already defined in our Condition part, don't do it again.
            // Also need this for ID generation.


            Dictionary <string, string> conditionsById = new Dictionary <string, string>();

            foreach (condition xx in conditions.condition)
            {
                conditionsById.Add(xx.id, "");
                if (xx.Item is xpathref)
                {
                    xpathref ex = (xpathref)xx.Item;

                    if (ex.id.Equals(xpath.id))
                    {
                        result = xx;
                        log.Info("This Condition is already setup, with ID: " + xx.id);
                        break;
                    }
                }
            }



            if (result == null) // not already defined
            {
                // Add the new condition
                result = new condition();
                //result.id = IdGenerator.generateIdForXPath(conditionsById, null, null, xpath.dataBinding.xpath);
                result.id = IdHelper.GenerateShortID(5);

                xpathref xpathref = new xpathref();
                xpathref.id = xpath.id;

                result.Item = xpathref;

                conditions.condition.Add(result);

                // Save the conditions in docx
                string ser = conditions.Serialize();
                log.Info(ser);
                CustomXmlUtilities.replaceXmlDoc(model.conditionsPart, ser);
            }

            // Set this
            conditionId = result.id;

            log.Debug("Condition written!");

            return(result);
        }
Exemple #10
0
 public itemProperties(long Npn, long Nsn, condition Ncond, string Nname, bool NhasComponents, Item[] Ncomponents)
 {
     pn            = Npn;
     sn            = Nsn;
     cond          = Ncond;
     name          = Nname;
     hasComponents = NhasComponents;
     components    = Ncomponents;
 }
Exemple #11
0
 public IEnumerator actionWithCondition(inProcess inProcess, condition condition, afterEnd afterEnd)
 {
     while (condition() == false)
     {
         inProcess?.Invoke();
         yield return(new WaitForEndOfFrame());
     }
     afterEnd?.Invoke();
 }
Exemple #12
0
        public void RunLine()
        {
            condition result = condition.run;

            while (result != condition.finish)
            {
                result = ProcessElem();
            }
        }
Exemple #13
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description")] condition condition)
 {
     if (ModelState.IsValid)
     {
         db.Entry(condition).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(condition));
 }
Exemple #14
0
    /// <summary>
    /// Interrupts pursuer's movement.
    /// </summary>
    /// <returns>False, if pursuer not in Movement state at the call moment.</returns>
    public bool InterruptMovement()
    {
        if (curCond == Movement)
        {
            ThrowUniversalEvent("EventMovementWasInterrupted");
            curCond = WaitingForTheContinuation;
            return(true);
        }

        return(false);
    }
Exemple #15
0
    /// <summary>
    /// Resumes pursuer's movement.
    /// </summary>
    /// <returns>False, if pursuer not in WaitingForTheContinuation state at the call moment.</returns>
    public bool ResumeMovement()
    {
        if (curCond == WaitingForTheContinuation)
        {
            ThrowUniversalEvent("EventMovementWasResumed");
            curCond = Movement;
            return(true);
        }

        return(false);
    }
Exemple #16
0
        public ActionResult Create([Bind(Include = "Id,Name,Description")] condition condition)
        {
            if (ModelState.IsValid)
            {
                db.conditions.Add(condition);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(condition));
        }
Exemple #17
0
    public int endCondition <condition>() where condition : BaseCondition
    {
        condition preexisting = getCondition <condition>();

        if (preexisting != null)
        {
            int mult = preexisting.getMult();
            preexisting.abruptEnd();
            return(mult);
        }
        return(0);
    }
Exemple #18
0
    /// <summary>
    /// Allows to start pathfinding method.
    /// (Calls from SpaceManager, when the queue is pumping to the moment, the turn comes to this Pursuer)
    /// </summary>
    public void AllowPathfinding()
    {
        if (GetCurCondition() == "WaitingForPursuersQueue")
        {
            ThrowUniversalEvent("EventPathfindingQueueCameUp");
            curCond = WaitingForAWay;

            ThrowUniversalEvent("EventPathfindingStarted");
            FindWay(thisTransformInstance.position, targetCoord, pathfindingLevel, foundPath, selectedPFAlg,
                    defaultFailureAct, defaultSuccesAct);
        }
    }
Exemple #19
0
        /// <summary>
        /// Returns a list of all contracts that meet the requierment
        /// </summary>
        /// <param name="cond">condition delegate</param>
        public List <Contract> GetContractByCondition(condition cond)
        {
            List <Contract> newList;

            foreach (Contract item in GetAllContract)
            {
                if (cond)
                {
                    newList.Add(item);
                }
            }
            return(newList);
        }
Exemple #20
0
        /// <summary>
        /// Returns the number of all contracts that meet the requierment
        /// </summary>
        /// <param name="cond">condition delegate</param>
        public List <Contract> GetNumOfContractsStandingOnCondition(condition cond)
        {
            int num = 0;

            foreach (Contract item in GetAllContract)
            {
                if (cond)
                {
                    num++;
                }
            }
            return(num);
        }
Exemple #21
0
        // GET: Condition/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            condition condition = db.conditions.Find(id);

            if (condition == null)
            {
                return(HttpNotFound());
            }
            return(View(condition));
        }
Exemple #22
0
        public List <Test> AlltestsThat(condition Mycondition)
        {
            List <Test>        myList  = new List <Test>();
            IEnumerable <Test> allTest = dal.GetAllTests();

            foreach (Test t in allTest)
            {
                if (Mycondition(t))
                {
                    myList.Add(t);
                }
            }
            return(myList);
        }
Exemple #23
0
    public float CalculateValue(condition c, long pn)
    {
        // TODO: Look elsewhere to find market value for the item USING THE "pn"
        // e.g. float inVal = searchDBValue(pn);

        // Ensuring value of item found using pn is round to 2dp
        float inVal = 10.20f;
        //float outVal    = Math.Round(inVal, 2);

        // Calculating condition multiplier for value of item
        float condMulti = CalculateCondMulti(c);

        // Finally multiply the outVal * condMulti to arrive at final return value
        return(inVal * condMulti);
    }
Exemple #24
0
 /// <summary>
 /// Valorized constuctor of the class. It represents a chunk already downloaded because a payload
 /// is passed to the method. The condition of the chunk is automatically set to DOWNLOADED.
 /// </summary>
 /// <param name="payload">The payload contained into the chunk.</param>
 public BufferChunk(byte[] payload)
 {
     this.Payload = payload;
     this.actualCondition = condition.DOWNLOADED;
 }
Exemple #25
0
 /// <summary>
 /// Default constructor of the class. It limits itself to only set the state of the chunk by default
 /// in CLEAN condition.
 /// </summary>
 public BufferChunk()
 {
     this.actualCondition = condition.CLEAN;
 }
Exemple #26
0
 /// <summary>
 /// Utility method used to clean the state of a chunk. It has the signature of an event method
 /// because it is passed to a timer class.
 /// </summary>
 /// <param name="source">ND</param>
 /// <param name="e">ND</param>
 private void cleaner(object source, EventArgs e)
 {
     if (this.actualCondition == condition.DIRTY)
     {
         this.actualCondition = condition.CLEAN;
     }
 }
        /// <summary>
        /// Sets the objective to a starting state. This way, an objective may be
        /// predictable when reused.
        /// 
        /// Notably registers event handlers.
        /// </summary>
        /// <param name="gameReference">A reference to the game so that the event
        /// manager is accessible. Also, other initializing actions may be taken.</param>
        public virtual void Initialize(Pantheon gameReference)
        {
            // Register the objective's handler in the event manager
            HandleEvent eventHandler = this.HandleNotification;
            gameReference.EventManager.register(this.EventType, eventHandler);

            state = condition.active;
        }
 /// <summary>
 /// An event handler meant to be registered with the event manager.
 /// </summary>
 /// <param name="eventinfo">The event data passed to the handler</param>
 public virtual void HandleNotification(Event eventinfo)
 {
     state = condition.complete;
 }
 private static string GetCondition(FetchEntityType entity, condition condition, FetchXmlBuilder sender)
 {
     var result = "";
     if (!string.IsNullOrEmpty(condition.attribute))
     {
         GetEntityMetadata(entity.name, sender);
         var attrMeta = FetchXmlBuilder.GetAttribute(entity.name, condition.attribute);
         if (attrMeta == null)
         {
             throw new Exception($"No metadata for attribute: {entity.name}.{condition.attribute}");
         }
         result = attrMeta.SchemaName;
         switch (attrMeta.AttributeType)
         {
             case AttributeTypeCode.Picklist:
             case AttributeTypeCode.Money:
             case AttributeTypeCode.State:
             case AttributeTypeCode.Status:
                 result += "/Value";
                 break;
             case AttributeTypeCode.Lookup:
                 result += "/Id";
                 break;
         }
         switch (condition.@operator)
         {
             case @operator.eq:
             case @operator.ne:
             case @operator.lt:
             case @operator.le:
             case @operator.gt:
             case @operator.ge:
                 result += $" {condition.@operator} ";
                 break;
             case @operator.neq:
                 result += " ne ";
                 break;
             case @operator.@null:
                 result += " eq null";
                 break;
             case @operator.notnull:
                 result += " ne null";
                 break;
             case @operator.like:
                 result = $"substringof('{condition.value}', {attrMeta.SchemaName})";
                 break;
             case @operator.notlike:
                 result = $"not substringof('{condition.value}', {attrMeta.SchemaName})";
                 break;
             case @operator.@in:
             case @operator.notin:
                 throw new Exception($"Condition operator '{condition.@operator}' is not yet supported by the OData generator");
             default:
                 throw new Exception($"Unsupported OData condition operator '{condition.@operator}'");
         }
         if (!string.IsNullOrEmpty(condition.value) && condition.@operator != @operator.like && condition.@operator != @operator.notlike)
         {
             switch (attrMeta.AttributeType)
             {
                 case AttributeTypeCode.Money:
                 case AttributeTypeCode.BigInt:
                 case AttributeTypeCode.Boolean:
                 case AttributeTypeCode.Decimal:
                 case AttributeTypeCode.Double:
                 case AttributeTypeCode.Integer:
                 case AttributeTypeCode.State:
                 case AttributeTypeCode.Status:
                 case AttributeTypeCode.Picklist:
                     result += condition.value;
                     break;
                 case AttributeTypeCode.Uniqueidentifier:
                 case AttributeTypeCode.Lookup:
                 case AttributeTypeCode.Customer:
                 case AttributeTypeCode.Owner:
                     result += $"(guid'{condition.value}')";
                     break;
                 case AttributeTypeCode.DateTime:
                     result += $"datetime'{condition.value}'";
                     break;
                 default:
                     result += $"'{condition.value}'";
                     break;
             }
         }
     }
     return result;
 }
Exemple #30
0
 public WhereItem(string fieldName, condition con, string value)
 {
     _FieldName = fieldName;
     _Condition = con;
     _Value = value;
 }