private void useSpecialIfPossible(ISpecial ability)
 {
     //TODO: add debug/actual messages saying why ability failed
     if (ability.isReady() && resources.currentEnergy > ability.energyRequired)
     {
         if (ability.GetAction() == AbilityHelper.Action.Equip)
         {
             ability.Execute(player, gameObject, gameObject);
             activeSpecialAbility = ability;
         }
         else if (ability.GetAction() == AbilityHelper.Action.AOE)
         {
             Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             if (Physics.Raycast(ray, out hit, 100f, Layers.Floor))
             {
                 aoeArea = Instantiate(ability.aoeTarget, hit.point, Quaternion.Euler(-90, 0, 0)) as GameObject;
             }
             else
             {
                 aoeArea = Instantiate(ability.aoeTarget, transform.position, Quaternion.Euler(-90, 0, 0)) as GameObject;
             }
             aoeArea.GetComponent <AOETargetController>().effectiveRange = ability.effectiveRange;
             navMeshAgent.Resume();
             activeSpecialAbility = ability;
             //AimAOE
         }
         else if (ability.GetAction() == AbilityHelper.Action.Target || ability.GetAction() == AbilityHelper.Action.TargetFriend)
         {
             activeSpecialAbility = ability;
             //AimTarget
         }
     }
 }
    private void cancelSpecialIfPossible(ISpecial ability)
    {
        if (ability.GetAction() == AbilityHelper.Action.AOE)
        {
            if (aoeArea != null)
            {
                Destroy(aoeArea);
                aoeArea = null;
            }
        }
        else if (ability.GetAction() == AbilityHelper.Action.Target)
        {
            if (specialTargetedEnemy != null)
            {
                navMeshAgent.destination = transform.position;
                specialTargetedEnemy     = null;
            }
        }
        else if (ability.GetAction() == AbilityHelper.Action.TargetFriend)
        {
            if (specialTargetedFriend != null)
            {
                navMeshAgent.destination = transform.position;
                specialTargetedFriend    = null;
            }
        }

        //happens in all abilities EXCEPT Equip, since Equip cannot be cancelled
        if (ability.GetAction() != AbilityHelper.Action.Equip)
        {
            activeSpecialAbility = null;
        }
    }
 private static string GenerateCode(string sourceCode, SupportedLanguage language)
 {
     using (IParser parser = ParserFactory.CreateParser(language, new StringReader(sourceCode)))
     {
         parser.Parse();
         if (parser.Errors.Count == 0)
         {
             IList <ISpecial>  savedSpecialsList = new ISpecial[0];
             IOutputAstVisitor targetVisitor;
             if (language == SupportedLanguage.CSharp)
             {
                 targetVisitor = new VBNetOutputVisitor();
             }
             else
             {
                 targetVisitor = new CSharpOutputVisitor();
             }
             using (SpecialNodesInserter.Install(savedSpecialsList, targetVisitor))
             {
                 parser.CompilationUnit.AcceptVisitor(targetVisitor, null);
             }
             return(targetVisitor.Text);
         }
         StringBuilder errorBuilder = new StringBuilder();
         return(parser.Errors.ErrorOutput);
     }
 }
    private void ShootSpecialOnFriendTarget(Transform target)
    {
        if (target == null)
        {
            return;
        }
        float remainingDistance = Vector3.Distance(target.position, transform.position);

        if (remainingDistance <= activeSpecialAbility.effectiveRange)
        {
            //Within range, look at enemy and shoot
            transform.LookAt(target);
            //animController.AnimateAimStanding();

            if (activeSpecialAbility.isReady())
            {
                activeSpecialAbility.Execute(player, gameObject, target.gameObject);
                activeSpecialAbility  = null;
                specialTargetedFriend = null;
            }

            navMeshAgent.destination = transform.position;
            animSpeed = 0.0f;
        }
    }
Example #5
0
 public StartTestController(IOsn osn, ISpecial spec, IDisciples disc, ISpecializations sp)
 {
     this.osn  = osn;
     this.spec = spec;
     this.disc = disc;
     this.sp   = sp;
 }
Example #6
0
    //sets aiPlayer.activeSpecialAbility
    private void EvaluateSpecial()
    {
        bool specialAbilityReady = false;
        int  i;

        for (i = 0; i < aiPlayer.abilities.abilityArray.Length && !specialAbilityReady; i++)
        {
            ISpecial potentialAbility = aiPlayer.abilities.abilityArray[i];
            //maybe to "dumbify" ai make it some ratio of time since ready to full cooldown?
            //note: empty ability always returns false on isReady
            if (potentialAbility.isReady() && potentialAbility.energyRequired < aiPlayer.player.resources.currentEnergy && MatchesAbilityPref(potentialAbility))
            {
                //Decide whether to use ability or continue searching (sorry this got kinda complicated!), might want a separate method?

                if (potentialAbility.EvaluateCoopUse(aiPlayer.player, aiPlayer.targetedEnemy, aiPlayer.tm))
                {
                    aiPlayer.activeSpecialAbility = potentialAbility;
                }
                else
                {
                    aiPlayer.activeSpecialAbility = null;
                }

                if (aiPlayer.activeSpecialAbility != null)
                {
                    specialAbilityReady = true;
                }

                //Debug.Log("Evaluating ability " + i);
            }
        }
    }
    public ISpecial GetSpecial()
    {
        ISpecial special = currentSpecials[0];

        currentSpecials.RemoveAt(0);
        return(special);
    }
    private void ShootSpecialOnTarget(Transform target)
    {
        if (target == null)
        {
            return;
        }
        float remainingDistance = Vector3.Distance(target.position, transform.position);

        if (remainingDistance <= activeSpecialAbility.effectiveRange && isTargetVisible(target))
        {
            //Within range, look at enemy and shoot
            transform.LookAt(target);
            //animController.AnimateAimStanding();

            if (activeSpecialAbility.isReady() && !target.GetComponent <EnemyHealth>().isDead)
            {
                activeSpecialAbility.Execute(player, gameObject, target.gameObject);

                if (specialTargetedEnemy != null && target.GetComponent <EnemyHealth>().isDead)
                {
                    if (changeTargetOnSpecial)
                    {
                        targetedEnemy = null;
                    }
                }
                activeSpecialAbility = null;
                specialTargetedEnemy = null;
            }

            navMeshAgent.destination = transform.position;
            animSpeed = 0.0f;
        }
    }
Example #9
0
 /// <summary>
 /// Sets the code documentation comments associated with this <see cref="INode"/>.
 /// </summary>
 ///
 /// <param name="node">
 /// The <see cref="INode"/> to associate code documentation comments to.
 /// </param>
 ///
 /// <param name="special">
 /// An <see cref="ISpecial"/> implementation which is likely an instance of <see cref="Comment"/> from which
 /// the value of <see cref="Comment.CommentText"/> will be extracted.
 /// </param>
 public static void SetDocumentation(this INode node, ISpecial special)
 {
     if (special is Comment)
     {
         var comment = (Comment)special;
         SetDocumentation(node, comment.CommentText);
     }
 }
        private bool specialHasBeenHandled(ISpecial special)
        {
            int  posOfStart     = startAndEndContainer.NodeStart.IndexOf(special);
            int  posOfEnd       = startAndEndContainer.NodeEnd.IndexOf(special);
            bool alreadyHandled = (posOfStart == posOfEnd) && (posOfStart != -1);

            return(alreadyHandled);
        }
Example #11
0
 internal static bool IsDocumentationComment(ISpecial special)
 {
     if (special is Comment)
     {
         var comment = (Comment)special;
         return(comment.CommentType == CommentType.Documentation);
     }
     return(false);
 }
 public object Visit(ISpecial special, object data)
 {
     if (!specialHasBeenHandled(special))
     {
         Console.WriteLine("Warning: SpecialOutputVisitor.Visit(ISpecial) called with " + special);
         considerSpecialAsHandled(special);
     }
     return(data);
 }
Example #13
0
 //puts ability into the displayed players ability array at spot
 public void updateSpecialAbilities(int spot, ISpecial ability)
 {
     displayedPlayer.abilities.SetNewAbility(ability.id, spot);
     ISpecial[] array = displayedPlayer.abilities.abilityArray;
     displayedPlayer.attributes.ResetPassiveBonus();
     foreach (ISpecial x in array)
     {
         x.updatePassiveBonuses(displayedPlayer.attributes);
     }
 }
Example #14
0
 //called by strategy when switching from ai -> player
 public void ResetOnSwitch()
 {
     targetedEnemy = null;
     currentState  = idleState;
     StopAllCoroutines();
     navMeshAgent.speed = navSpeedDefault;
     if (abilities != null)
     {
         activeSpecialAbility = null;
     }
 }
 private void AimAOESpecial()
 {
     //raycasting is handled by script attached to aoeArea
     if (Input.GetButtonDown("Fire1"))
     {
         activeSpecialAbility.Execute(player, gameObject, aoeArea);
         aoeArea.GetComponent <AOETargetController>().DisableTracking();
         aoeArea = null; //if switch player, aoeArea will be null so it will still exist if cast
         activeSpecialAbility = null;
     }
 }
        public void Setup()
        {
            priceSpecial = new PriceSpecial("Can of soup", 2, true, 5);

            limitSpecialNoLimit = new LimitSpecial("Can of soup", 2, true, 1, 0.5f, 0);

            restrictionSpecialLesser = new RestrictionSpecial("Can of soup", 2, true, 1, 0.5f, RestrictionType.Lesser);

            nonExistentPriceSpecial = new PriceSpecial("Can of beans", 2, true, 6);

            updatedPriceSpecial = new PriceSpecial("Can of soup", 2, true, 6);
        }
 public void ResetOnSwitch()
 {
     targetedEnemy            = null;
     navMeshAgent.speed       = navSpeedDefault;
     navMeshAgent.destination = transform.position;
     inheritDefendState       = false;
     specialTargetedFriend    = null;
     animSpeed            = 0.0f;
     specialTargetedEnemy = null;
     activeSpecialAbility = null;
     firstClick           = false;
     if (aoeArea != null)
     {
         Destroy(aoeArea);
     }
 }
        public bool TryGetBlob(int id, out ISpecial outBlob)
        {
            // set default value for output parameter
            outBlob = null;

            foreach (ISpecial blob in dictBlobs.Values)
            {
                bool success = blob.IsSpecial(id);

                if (success)
                {
                    return(dictBlobs.TryGetValue(blob.BlobType, out outBlob));
                }
            }

            return(false);
        }
        public SpecialFactory()
        {
            dictBlobs = new Dictionary <SpecialType, ISpecial>();

            ISpecial[] blobArr = new ISpecial[]
            {
                new Grayscale(),
                new Ice(),
                new Fire(),
                new Wind()
            };

            foreach (ISpecial blob in blobArr)
            {
                dictBlobs.Add(blob.BlobType, blob);
            }
        }
			string RetrieveDocumentation (int upToLine)
			{
				StringBuilder result = null;
				while (lastSpecial < specials.Count) {
					ISpecial cur = specials[lastSpecial];
					if (cur.StartPosition.Line >= upToLine)
						break;
					ICSharpCode.NRefactory.Comment comment = cur as ICSharpCode.NRefactory.Comment;
					if (comment != null && comment.CommentType == ICSharpCode.NRefactory.CommentType.Documentation) {
						if (result == null)
							result = new StringBuilder ();
						result.Append (comment.CommentText);
					}
					lastSpecial++;
				}
				return result == null ? null : result.ToString ();
			}
    // Update is called once per frame
    void FixedUpdate()
    {
        ISpecial abil = tm.activePlayer.abilities.abilityArray[index];

        if (abil != null)
        {
            bool visible = !(abil.isReady());
            Overlay.gameObject.SetActive(visible);
            Timer.gameObject.SetActive(visible);
            if (visible)
            {
                float timeLeft  = abil.RemainingTime();
                float totalTime = abil.coolDownTime;
                Overlay.fillAmount = timeLeft / totalTime;
                Timer.text         = ((int)Mathf.Ceil(timeLeft)).ToString();
            }
        }
    }
Example #22
0
    private bool MatchesAbilityPref(ISpecial ability)
    {
        bool matches = false;

        AbilityHelper.CoopAction act = ability.GetCoopAction();
        if (aiPlayer.abilityChoose == Strategy.AbilityPref.Offensive)
        {
            matches = act == AbilityHelper.CoopAction.AOEHurt || act == AbilityHelper.CoopAction.Equip || act == AbilityHelper.CoopAction.TargetHurt || ability.id == 10; //special case for invigorate
        }
        else if (aiPlayer.abilityChoose == Strategy.AbilityPref.Defensive)
        {
            matches = act == AbilityHelper.CoopAction.AOEHeal || act == AbilityHelper.CoopAction.Equip || act == AbilityHelper.CoopAction.TargetHeal || act == AbilityHelper.CoopAction.InstantHeal;
        }
        else
        {
            matches = true;
        }
        return(matches);
    }
Example #23
0
    public void InstantiateSpecial()
    {
        if (specialInUse != null)
        {
            Destroy(specialInUse.GetGameObject());
        }

        GameObject instSpecial;

        switch (playerShipData.GetSpecial())
        {
        default:
        {
            instSpecial = Instantiate(PrefabManager.currentInstance.special_deflectPulse) as GameObject;
            break;
        }
        }
        instSpecial.SetActive(false);
        specialInUse = instSpecial.GetComponent <ISpecial>();
    }
Example #24
0
        // the not-combined offer pricing method, prices each item independently, WILL NOT HANDLE COMBINED SPECIAL OFFERS
        public Decimal PriceNotCombined(string itemName, int qty)
        {
            if (!Items.ContainsKey(itemName.ToUpper()))
            {
                throw new Exception(String.Format("Item '{0}' is not a valid item.", itemName));
            }

            IItem   item     = Items[itemName.ToUpper()];
            Decimal prc      = item.Price;
            string  specCode = item.SpecialCode?.ToUpper();

            if (!String.IsNullOrEmpty(specCode) && Specials.ContainsKey(specCode))
            {
                ISpecial spec = Specials[specCode];
                Total += (prc * spec.For * (int)(qty / spec.Quantity)) + (prc * (int)(qty % spec.Quantity));
                return(-1.0M);
            }

            // no special offer, just regular price
            return(qty * prc);
        }
    public void ReciveInput(input pInput, Player player)
    {
        if (player.Alive)
        {
            switch (pInput)
            {
            case input.shoot:
                player.shoots = true;
                break;

            case input.special:
                if (player.HasSpecial())
                {
                    Debug.Log("SPECIAL Shoot!!");
                    ISpecial playerSpecial = player.GetSpecial();
                    playerSpecial.Call(player.GetPos, player.GetID);
                    displayedSpecials.Add(playerSpecial);
                }
                break;

            case input.up:
                player.TryToMove(new Vector2Int(0, -1));
                break;

            case input.right:
                player.TryToMove(new Vector2Int(1, 0));
                break;

            case input.left:
                player.TryToMove(new Vector2Int(-1, 0));
                break;

            case input.down:
                player.TryToMove(new Vector2Int(0, 1));
                break;
            }
        }
    }
Example #26
0
        // GetPrice() calculates and retrieves the final price
        public Decimal GetPrice()
        {
            // go through all special collections
            foreach (var sc in specLists)
            {
                ISpecial       spec   = Specials[sc.Key];
                List <Decimal> sorted = sc.Value.OrderByDescending(x => x).ToList();

                int len    = sorted.Count();
                int payFor = 0;
                int free   = 0;
                for (int i = 0; i < len;)
                {
                    if (payFor < spec.For)
                    {
                        Total += sorted[i];
                        payFor++;
                        i++;
                    }
                    else
                    {
                        if (free < spec.Quantity - spec.For)
                        {
                            len--;      // the cheapest one is free
                            free++;
                        }
                        else
                        {
                            // we have given away the free ones, now they need to buy again
                            payFor = free = 0;
                        }
                    }
                }
            }

            // we have the total price now
            return(Total);
        }
 public SecondardyMainViewModel(ISpecial special)
 {
     Data = "Is special - " + special.Data;
 }
		public object Visit(ISpecial special, object data)
		{
			Console.WriteLine("Warning: SpecialOutputVisitor.Visit(ISpecial) called with " + special);
			return data;
		}
Example #29
0
 public ThirdFourViewModel(ISpecial special)
 {
     Title = special.Data;
 }
 public bool IsCommentType(ISpecial special)
 {
     try
     {
         var comment = (Comment)special;
         return true;
     }
     catch
     {
         return false;
     }
 }
Example #31
0
 public absctract void DoSomething(ref ISpecial special);         // Force all derived classes to implement this method
 /// <summary>
 /// Sets the code documentation comments associated with this <see cref="INode"/>.
 /// </summary>
 /// 
 /// <param name="node">
 /// The <see cref="INode"/> to associate code documentation comments to.
 /// </param>
 /// 
 /// <param name="special">
 /// An <see cref="ISpecial"/> implementation which is likely an instance of <see cref="Comment"/> from which
 /// the value of <see cref="Comment.CommentText"/> will be extracted.
 /// </param>
 public static void SetDocumentation (this INode node, ISpecial special)
 {
     if (special is Comment)
     {
         var comment = (Comment)special;
         SetDocumentation (node, comment.CommentText);
     }
 }
 internal static bool IsDocumentationComment (ISpecial special)
 {
     if (special is Comment)
     {
         var comment = (Comment) special;
         return comment.CommentType == CommentType.Documentation;
     }
     return false;
 }
        public string GetTypeName(string csFile, ISpecial comment, ref int lineRef)
        {
            var result = "";
            try
            {
                FileStream fs = new FileStream(csFile, FileMode.Open);
                StreamReader sr = new StreamReader(fs);

                string line = "";

                int lineNo = 1;
                do
                {
                    line = sr.ReadLine();
                    if (line != null)
                    {
                        if (lineNo > comment.EndPosition.Line)
                        {
                            line = line.Trim();
                            if (IsMethod(line))
                            {
                                var pos = line.IndexOf('(');
                                var comps = line.Substring(0, pos).Split(new char[] { ' ' });
                                result = comps[comps.Length - 1];
                                lineRef = lineNo;
                                break;
                            }
                            else if (IsClass(line))
                            {
                                var comps = line.Split(new char[] { ' ' });
                                result = comps[comps.Length - 1];
                                lineRef = lineNo;
                                break;
                            }
                        }
                        lineNo++;
                    }
                    
                } while (line != null);

                sr.Close();
                fs.Close();
            }
            catch
            {
                result = "";
            }
            return result;
        }
Example #35
0
 public override void DoSomething(ref ISpecial special)
 {
     DoSomethingBase(ref special);     // if you need some base class logic
     special = special.AddFields(SpecialOffer, OptionPack);
 }
Example #36
0
    public absctract void DoSomething(ref ISpecial special);         // Force all derived classes to implement this method

    protected virtual void DoSomethingBase(ref ISpecial special)
    {
        special = special.AddFields(Rego, ModelNumber)
    }
 public MainViewModel(ISpecial special)
 {
     Data = special.Data;
 }
 public object Visit(ISpecial special, object data)
 {
     Console.WriteLine("Warning: SpecialOutputVisitor.Visit(ISpecial) called with " + special);
     return(data);
 }
		object ISpecialVisitor.Visit(ISpecial special, object data)
		{
			throw new NotImplementedException();
		}