Example #1
0
		internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary<string, XmlElement> processed)
		{
			base.SetXML(xml, host, processed); 
			xml.AppendChild(StartPoint.GetXML(xml.OwnerDocument, "StartPoint", this, processed));
			setAttribute(xml, "StartDirection", StartDirection.ToString());
			xml.SetAttribute("StartRadiusOfCurvature", mStartRadiusOfCurvature.ToString());
			xml.SetAttribute("EndRadiusOfCurvature", mEndRadiusOfCurvature.ToString());
			xml.SetAttribute("SegmentLength", mSegmentLength.ToString());
			if (!double.IsNaN(mGravityCenterLineHeight))
				xml.SetAttribute("GravityCenterLineHeight", mGravityCenterLineHeight.ToString());
			xml.SetAttribute("PredefinedType", mPredefinedType.ToString().ToLower());
		}
    void Update()
    {
        TargetPlayer();

        if (!playerSeen && !die)
        {
            walkedDistance = Mathf.Abs(gameObject.transform.position.x - referencePosition);

            if (walkedDistance >= maxPingPong)
            {
                if (direction == StartDirection.Left)
                {
                    direction               = StartDirection.Right;
                    enemySprite.flipX       = true;
                    bulletPos.localPosition = new Vector3(0.21f, 0.09f);
                }
                else
                {
                    direction               = StartDirection.Left;
                    enemySprite.flipX       = false;
                    bulletPos.localPosition = new Vector3(-0.21f, 0.09f);
                }
                referencePosition = gameObject.transform.position.x;
            }

            if (direction == StartDirection.Left)
            {
                speed = -Mathf.Abs(speed);
            }
            else
            {
                speed = Mathf.Abs(speed);
            }

            gameObject.transform.Translate(new Vector3(speed, 0, 0) * Time.deltaTime);
        }
    }