Beispiel #1
0
        public BackgroundCreature(BackgroundCreaturePrefab prefab, Vector2 position)
        {
            this.Prefab   = prefab;
            this.position = position;

            drawPosition = position;

            steeringManager = new SteeringManager(this);

            velocity = new Vector3(
                Rand.Range(-prefab.Speed, prefab.Speed, Rand.RandSync.ClientOnly),
                Rand.Range(-prefab.Speed, prefab.Speed, Rand.RandSync.ClientOnly),
                Rand.Range(0.0f, prefab.WanderZAmount, Rand.RandSync.ClientOnly));

            checkWallsTimer = Rand.Range(0.0f, CheckWallsInterval, Rand.RandSync.ClientOnly);

            foreach (XElement subElement in prefab.Config.Elements())
            {
                List <SpriteDeformation> deformationList = null;
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "deformablesprite":
                    deformationList = spriteDeformations;
                    break;

                case "deformablelightsprite":
                    deformationList = lightSpriteDeformations;
                    break;

                default:
                    continue;
                }
                foreach (XElement animationElement in subElement.Elements())
                {
                    SpriteDeformation deformation = null;
                    int sync = animationElement.GetAttributeInt("sync", -1);
                    if (sync > -1)
                    {
                        string typeName = animationElement.GetAttributeString("type", "").ToLowerInvariant();
                        deformation = uniqueSpriteDeformations.Find(d => d.TypeName == typeName && d.Sync == sync);
                    }
                    if (deformation == null)
                    {
                        deformation = SpriteDeformation.Load(animationElement, prefab.Name);
                        if (deformation != null)
                        {
                            uniqueSpriteDeformations.Add(deformation);
                        }
                    }
                    if (deformation != null)
                    {
                        deformationList.Add(deformation);
                    }
                }
            }
        }
        public BackgroundCreature(BackgroundCreaturePrefab prefab, Vector2 position)
        {
            this.prefab = prefab;

            this.position = position;

            drawPosition = position;

            steeringManager = new SteeringManager(this);

            velocity = new Vector3(
                Rand.Range(-prefab.Speed, prefab.Speed),
                Rand.Range(-prefab.Speed, prefab.Speed),
                Rand.Range(0.0f, prefab.WanderZAmount));

            checkWallsTimer = Rand.Range(0.0f, CheckWallsInterval);
        }