Beispiel #1
0
    void OnCollisionEnter(Collision collision)
    {
        foreach (ContactPoint contact in collision.contacts)
        {
            //Debug.Log(LayerMask.LayerToName(contact.thisCollider.gameObject.layer) + " hit " + contact.otherCollider.gameObject);

            //If hand hit something
            if (contact.thisCollider.gameObject.layer.Equals(LayerMask.NameToLayer("Attack")))
            {
                GameObject other = contact.otherCollider.gameObject;
                //Debug.Log(other);
                other.GetComponent <Rigidbody>().AddForce(tagForce * -contact.normal, ForceMode.VelocityChange);
                if (tagScript.IsTag())
                {
                    TagScript otherTag = other.GetComponentInParent <TagScript>();
                    if (otherTag != null)
                    {
                        Debug.Log("TAGGED");
                        otherTag.SetTag(true);
                        this.tagScript.SetTag(false);
                    }
                }
                //Avoid Colliding many times
                handController.ToggleHandCollider(0);
                break;
            }
        }
    }
        private string MatchEvaluatorScript(Match m)
        {
            Type      tagType   = typeof(TagScript);
            TagScript tagObject = new TagScript();

            // Set the text
            SetProperty(tagType,
                        tagObject,
                        "Text",
                        m.Groups[RegExConstants.RE_CS_SCRIPT_TEXT].Value);

            if (m.Groups[RegExConstants.RE_CS_SCRIPT_KEY].Captures.Count > 0)
            {
                for (int i = 0; i < m.Groups[RegExConstants.RE_CS_SCRIPT_KEY].Captures.Count; i++)
                {
                    SetProperty(tagType,
                                tagObject,
                                m.Groups[RegExConstants.RE_CS_SCRIPT_KEY].Captures[i].Value,
                                m.Groups[RegExConstants.RE_CS_SCRIPT_VALUE].Captures[i].Value);
                }
            }

            // Add the templateobject to the list
            TemplateObjectList.Add(new TemplateObject(tagType, tagObject));

            return(string.Empty);
        }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindWithTag("Player").transform;

        navMeshAgent = GetComponent <NavMeshAgent>();

        taggingScript = GetComponent <TaggingParent>();
        tagScript     = GetComponent <TagScript>();
    }
 public void AddCondition(ConditionInstanceClass con, TagScript tagObject)
 {
     if (tagObject != null)
     {
         if (!conditionTags.ContainsKey(con.condition.name))
         {
             tagObject.condition = con;
             conditionTags.Add(con.condition.name, tagObject);
             conditionsBrowsed = false;
         }
     }
     else
     {
         Debug.Log("Tagscript no found");
     }
 }
		/// <summary>
		/// Initializes this tag in the correct context.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="tagScript">The script to which the tag belongs.</param>
		public override void InitializeContext(IMansionContext context, TagScript tagScript)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (tagScript == null)
				throw new ArgumentNullException("tagScript");

			// allow base to proces as well
			base.InitializeContext(context, tagScript);

			// get the name of the procedure
			var procedureName = GetRequiredAttribute<string>(context, "procedureName");

			// register the procedure
			tagScript.RegisterProcedure(context, procedureName, this);
		}
    void Update()
    {
        character = GameObject.FindWithTag("Character");
        tag1      = character.transform.GetChild(0).gameObject;
        tag2      = character.transform.GetChild(1).gameObject;
        tag3      = character.transform.GetChild(2).gameObject;

        tag1script      = tag1.GetComponent <TagScript>();
        tag2script      = tag2.GetComponent <TagScript>();
        tag3script      = tag3.GetComponent <TagScript>();
        killcoroutine   = PushAndKill(1.0f);
        addnewcharacter = AddNewChar(1.0f);

        throwup   = PushUp(1.0f);
        character = GameObject.FindWithTag("Character");
        rb        = character.GetComponent <Rigidbody2D>();



        soulPoints = tag1script.currentPoints + tag2script.currentPoints + tag3script.currentPoints;
        //Debug.Log("This souls value in points is: " + soulPoints);
        playerAnimator = character.GetComponent <Animator>();
    }
    public void AddConditionToMember()
    {
        TagScript temp = null;
        int       tempN;

        if (!string.IsNullOrEmpty(conditionEnterer.text))
        {
            if (!int.TryParse(conditionAgeEnterer.text, out tempN))
            {
                tempN = 0;
            }

            if (string.IsNullOrEmpty(conditionDetailEnterer.text))
            {
                conditionDetailEnterer.text = "";
            }

            selectedMember.AddCondition(new ConditionInstanceClass(ConditionGlossary.GetCondition(conditionEnterer.text), conditionDetailEnterer.text, tempN));
        }
        else
        {
            LogError("You must specify the condition!");
        }
    }
Beispiel #8
0
 public static TagScript xmlspace(this TagScript tag, string value)
 {
     tag.XmlSpace = value; return(tag);
 }
Beispiel #9
0
 public static TagScript defer(this TagScript tag, Defer value)
 {
     tag.Defer = value; return(tag);
 }
Beispiel #10
0
 public static TagScript src(this TagScript tag, string value)
 {
     tag.Src = value; return(tag);
 }
Beispiel #11
0
 public static TagScript type(this TagScript tag, MimeType value)
 {
     tag.Type = value; return(tag);
 }
Beispiel #12
0
 public static TagScript charset(this TagScript tag, Charset value)
 {
     tag.Charset = value; return(tag);
 }
        public static string CreateContents(string nameSpace, string className, string classDefaultInherit, List <TemplateObject> templateObjectList, string templateName)
        {
            StringBuilder result         = new StringBuilder();
            int           currentIndent  = 0;
            int           indentIncrease = 4;

            // Check if this is a special case like Core.cst where there is only one TagText
            // in the whole templateObjectList.
            if (templateObjectList.Count == 1 &&
                templateObjectList[0].TagType == typeof(TagText))
            {
                TagText tText = (TagText)templateObjectList[0].Object;

                // Check if a namespace is defined somewhere, then ignore this
                if (Regex.Matches(tText.Text, @"^namespace\s+\w+\s*$").Count == 0)
                {
                    // Find using statement and i3 the namespace should be inserted
                    MatchCollection mc = Regex.Matches(tText.Text, RegExConstants.RE_CS_USINGSTATEMENTS);

                    // Must be only one match
                    if (mc.Count == 1)
                    {
                        result.Append(mc[0].Groups[RegExConstants.RE_CS_USINGSTATEMENTS_USING].Value);

                        // Add namespace tag
                        result.AppendLine(TemplateCreateNamespacePart(nameSpace, currentIndent));

                        currentIndent += indentIncrease;

                        result.AppendLine(BreakLinesAndOutput(mc[0].Groups[RegExConstants.RE_CS_USINGSTATEMENTS_RESTOFFILE].Value, currentIndent));

                        currentIndent -= indentIncrease;

                        result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

                        return(result.ToString());
                    }
                }
            }

            // Create the using statements
            TagImport tagImport = GetTemplateObject <TagImport>(templateObjectList);

            bool usingSystem = false;
            bool usingSystemCollectionsGeneric = false;
            bool usingCodesmithEngine          = false;

            while (tagImport != null)
            {
                result.AppendLine(TemplateCreateUsingPart(tagImport, currentIndent));

                if (tagImport.Namespace.Equals("System", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingSystem = true;
                }

                if (tagImport.Namespace.Equals("System.Collections.Generic", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingSystemCollectionsGeneric = true;
                }

                if (tagImport.Namespace.Equals("CodeSmith.Engine", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingCodesmithEngine = true;
                }

                tagImport = GetTemplateObject <TagImport>(templateObjectList);
            }

            // Add System and System.Collections.Generic

            if (!usingSystem)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("System"), currentIndent));
            }

            if (!usingSystemCollectionsGeneric)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("System.Collections.Generic"), currentIndent));
            }

            if (!usingCodesmithEngine)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("CodeSmith.Engine"), currentIndent));
            }

            result.AppendLine();

            // Create namespace tag
            result.AppendLine(TemplateCreateNamespacePart(nameSpace, currentIndent));

            currentIndent += indentIncrease;

            // Find the CodeTemplate object in list
            TagCodeTemplate tagCodeTemplate = GetTemplateObject <TagCodeTemplate>(templateObjectList);

            if (tagCodeTemplate != null &&
                tagCodeTemplate.Inherits != string.Empty)
            {
                result.AppendLine(TemplateCreateClassPart(className, tagCodeTemplate.Inherits, currentIndent));
            }
            else
            {
                result.AppendLine(TemplateCreateClassPart(className, classDefaultInherit, currentIndent));
            }

            currentIndent += indentIncrease;

            // Create the properties
            TagProperty tagProperty = GetTemplateObject <TagProperty>(templateObjectList);

            while (tagProperty != null)
            {
                result.AppendLine(TemplateCreateProperty(tagProperty.Name, tagProperty.Type, currentIndent));

                tagProperty = GetTemplateObject <TagProperty>(templateObjectList);
            }

            result.AppendLine();

            StringBuilder __text = new StringBuilder();

            result.AppendLine(string.Format("{0}public override string OriginalTemplateName {{ get {{ return @\"{1}\"; }} }}\r\n", GetIndent(currentIndent), templateName));

            string templateComment = @"Generated from template: " + templateName;

            // Override the Render function
            result.AppendLine(string.Format("{0}public override void Render()\r\n{0}{{\r\n{1}TagFile(@\"{2}\");", GetIndent(currentIndent), GetIndent(currentIndent + indentIncrease), templateComment));

            // Find all TagCSharp and TagText items and create the code from that
            for (int i = 0; i < templateObjectList.Count; i++)
            {
                TemplateObject obj = templateObjectList[i];

                if (obj.TagType == typeof(TagCSharp))
                {
                    result.Append(BreakLinesAndOutput(((TagCSharp)obj.Object).Code, currentIndent));
                }
                else if ((obj.TagType == typeof(TagText)) || (obj.TagType == typeof(TagParameter)))
                {
                    int lookAheadIndex = i + 1;

                    while (lookAheadIndex < templateObjectList.Count)
                    {
                        if ((templateObjectList[lookAheadIndex].TagType == typeof(TagText)) || (templateObjectList[lookAheadIndex].TagType == typeof(TagParameter)))
                        {
                            lookAheadIndex++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    // idx points to the next code fragment i.e. not Text or parameters

                    // create single string.format using the text and parameters
                    // advance i to skip ahead

                    // Do string replace " to "" and the other first ?? togr

                    string argumentList      = string.Empty;
                    int    stringFormatIndex = 0;

                    for (int i2 = i; i2 < lookAheadIndex; i2++)
                    {
                        argumentList = string.Concat(argumentList, string.Format("{{{0}}}", stringFormatIndex));
                        stringFormatIndex++;
                    }

                    StringBuilder code = new StringBuilder();
                    code.AppendLine(string.Format("__text.AppendFormat(\"{0}\\r\\n\"", argumentList));

                    for (int i3 = i; i3 < lookAheadIndex; i3++)
                    {
                        if (templateObjectList[i3].TagType == typeof(TagText))
                        {
                            TagText tText = (TagText)templateObjectList[i3].Object;

                            // Convert text. Change all " to ""
                            tText.Text = tText.Text.Replace("\"", "\"\"");

                            // Remove all consecutive \n and also all \n that is occuring alone not after a \r
                            tText.Text = Regex.Replace(tText.Text, "((?<=[^\r])\n)|(\n{2,})", string.Empty);
                            code.AppendLine(string.Format(",@\"{0}\"", tText.Text));
                        }
                        else
                        {
                            TagParameter tParam = (TagParameter)templateObjectList[i3].Object;
                            code.AppendLine(string.Format(",{0}", tParam.Parameter));
                        }
                    }

                    code.AppendLine(");");

                    result.Append(string.Format("{0}{1}", GetIndent(currentIndent), code.ToString()));
                    i = lookAheadIndex - 1;
                }
            }

            result.AppendLine(string.Format("{0}return;", GetIndent(currentIndent + indentIncrease)));

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            currentIndent -= indentIncrease;

            result.AppendLine();

            // Add the script section the properties
            TagScript tagScript = GetTemplateObject <TagScript>(templateObjectList);

            while (tagScript != null)
            {
                result.AppendLine(tagScript.Text);

                tagScript = GetTemplateObject <TagScript>(templateObjectList);
            }

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            currentIndent -= indentIncrease;

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            return(result.ToString());
        }
Beispiel #14
0
 void Start()
 {
     tagScript      = GetComponent <TagScript>();
     handController = GetComponentInChildren <HandController>();
 }