示例#1
0
        public void Update(float frameTime)
        {
            var movement = _speed * frameTime * (_up ? 1 : -1);

            Owner.Transform.LocalPosition += (0, movement);

            _duration    -= frameTime;
            _currentStep -= frameTime;

            if (_duration <= 0)
            {
                if (_rogue)
                {
                    Owner.RemoveComponent <PointingArrowComponent>();
                    Owner.AddComponent <RoguePointingArrowComponent>();
                    return;
                }

                Owner.Delete();
                return;
            }

            if (_currentStep <= 0)
            {
                _currentStep = _step;
                _up         ^= true;
            }
        }
示例#2
0
        protected override void OnInitialize()
        {
            for (int i = 0; i < Owner.ChildsCount; i++)
            {
                LineRenderer renderer = new LineRenderer(Owner)
                {
                    Texture     = Owner.Game.Content.Load <Texture2D>("blank"),
                    Destination = Owner.ChildAtIndex(i).Position,
                    Color       = new Color(Color.Gray, 125),
                    DrawOrder   = 0
                };

                Owner.AddComponent(renderer);
            }


            FloatingSpriteRenderer spriteRenderer = new FloatingSpriteRenderer(Owner, Owner.Position.Y - Owner.Game.Random.Next(5, 15), Owner.Position.Y + Owner.Game.Random.Next(5, 15));

            spriteRenderer.FollowOwner = false;
            spriteRenderer.Sprite      = new Sprite(Owner.Game.Content.Load <Texture2D>("greennode"));
            spriteRenderer.Position    = Owner.Position;
            spriteRenderer.DrawOrder   = 1;

            Owner.Size = spriteRenderer.Size;

            Owner.AddComponent(spriteRenderer);

            Owner.InitializeComponents();
        }
示例#3
0
        public void ApplyChanges()
        {
            var currentParticle = ParticleEntityFactory.CreateParticleSystem3D(currentParticleSystemIndex);

            Owner.RemoveComponent <ParticleSystem3D>();

            Owner.AddComponent(currentParticle);

            switch (currentParticleSystemIndex)
            {
            case 2:
            {
                var transform = Owner.FindComponent <Transform3D>();
                transform.Position = new Vector3(0f, 1000f, 0f);
                transform.Scale    = new Vector3(0.01f, 2f, 1f);
                break;
            }

            case 3:
            {
                var transform = Owner.FindComponent <Transform3D>();
                transform.Position = new Vector3(0f, 1000f, 0f);
                transform.Scale    = Vector3.One;
                break;
            }

            default:
            {
                var transform = Owner.FindComponent <Transform3D>();
                transform.Position = Vector3.Zero;
                transform.Scale    = Vector3.One;
                break;
            }
            }
        }
示例#4
0
        protected override void OnInitialize()
        {
            //InitializeMappings();

            StatSet         statSet         = StatSets.CreateWarriorStatSet(Owner);
            HealthComponent healthComponent = new HealthComponent(Owner, statSet);
            WeaponComponent weaponComponent = new WeaponComponent(Owner, Weapons.CreateSlicerClaymore());

            Owner.AddComponent(statSet);
            Owner.AddComponent(healthComponent);
            Owner.AddComponent(weaponComponent);

            Owner.InitializeComponents();

            spriterComponent.ChangeAnimation("Idle");
            spriterComponent.Scale = 0.4f;

            spriterComponent.OnAnimationChanged += spriterComponent_OnAnimationChanged;
            Owner.FirstComponentOfType <Wallet>().AddCoins(7000f);
            Owner.FirstComponentOfType <TargetingComponent>().Ignore("player");

            r = new DamageRenderer(Owner);
            r.Initialize();
            r.Color = Color.Green;

            Owner.AddComponent(r);
        }
        private void HandleUnEquipped()
        {
            Owner.AddComponent(ComponentFamily.Mover,
                               Owner.EntityManager.ComponentFactory.GetComponent("BasicMoverComponent"));

            /*Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null,
             *                                        EquippableComponentNetMessage.UnEquipped);*/
            currentWearer = null;
        }
示例#6
0
        protected override void OnInitialize()
        {
            spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Player\Player");
            spriterComponent.Initialize();
            spriterComponent.Scale = 0.2f;
            Owner.AddComponent(spriterComponent);

            Owner.InitializeComponents();
        }
示例#7
0
        public override void Awake()
        {
            AudioSpectrum audioSpectrum = Owner.AddComponent <AudioSpectrum>();

            audioSpectrum.numberOfSamples = (int)numberOfSamples;
            audioSpectrum.bandType        = (AudioSpectrum.BandType)System.Enum.ToObject(typeof(AudioSpectrum.BandType), (int)frequencyBandType);
            audioSpectrum.fallSpeed       = fallSpeed.Value;
            audioSpectrum.sensibility     = sensibility.Value;
        }
        private void HandleEquipped(Entity entity)
        {
            currentWearer = entity;
            Owner.AddComponent(ComponentFamily.Mover,
                               Owner.EntityManager.ComponentFactory.GetComponent("SlaveMoverComponent"));
            Owner.SendMessage(this, ComponentMessageType.SlaveAttach, entity.Uid);

            /* Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null,
             *                                         EquippableComponentNetMessage.Equipped, entity.Uid, wearloc);*/
        }
示例#9
0
        /// <summary>
        /// Called by framework. Do not call directly.
        /// </summary>
        protected override void OnAwake()
        {
            var rt = Owner.GetComponent <RectTransform>();

            if (rt == null)
            {
                rt = Owner.AddComponent <RectTransform>();
            }
            rt.LayoutChanged += UpdateLayout;
        }
示例#10
0
 protected override void OnUpdated()
 {
     count++;
     if (count == 10)
     {
         Owner.AddComponent(new ComponentAddingScene(), "Add");
         Console.WriteLine("vanish scene component.");
         Vanish();
     }
 }
示例#11
0
 protected override void OnLayerUpdated()
 {
     count++;
     if (count == 10)
     {
         Owner.AddComponent(new ComponentAddingLayer(), "Add");
         Console.WriteLine("vanish layer component.");
         Dispose();
     }
 }
示例#12
0
 protected override void OnUpdate()
 {
     count++;
     if (count == 10)
     {
         Owner.AddComponent(new ComponentAddingObject(), "Add");
         Console.WriteLine("vanish object component.");
         Dispose();
     }
 }
示例#13
0
        protected override void OnInitialize()
        {
            List <Scene> scenes = builder.BuildScenes(Owner);

            MapComponent mapComponent = new MapComponent(Owner, scenes);

            Owner.AddComponent(mapComponent);

            InitializeSpriteRenderers();

            CreateWalls();
        }
示例#14
0
文件: Player.cs 项目: anddonram/CODE3
        public void SetResources()
        {
            woodAmount   = 5000;
            keysBehavior = RenderManager.ActiveCamera2D.Owner.FindComponent <KeysBehavior>();
            ui           = UIBehavior.ui;
            map          = Map.map;
            fog          = FogOfWar.fog;
            PathDrawable draw = new PathDrawable();

            draw.SetPlayer(this, path);
            Owner.AddComponent(draw);
        }
示例#15
0
        private void spriterComponent_OnAnimationFinished(SaNi.Spriter.Data.SpriterAnimation animation)
        {
            spriterComponent.OnAnimationFinished -= spriterComponent_OnAnimationFinished;
            if (animation.Name != "Attack")
            {
                return;
            }

            GameObject target = Owner.FirstComponentOfType <TargetingComponent>().Target;

            spriterComponent.ChangeAnimation("Idle");
            // ei ole targettia
            if (target == null)
            {
                return;
            }

            // TODO siirrä johonkin komponenttiin kun on tarpeeksi abseja
            HealthComponent healthComponent = target.FirstComponentOfType <HealthComponent>();

            // Targettia vastaan ei voi hyökätä.
            if (healthComponent == null)
            {
                return;
            }

            WeaponComponent weaponComponent = Owner.FirstComponentOfType <WeaponComponent>();
            StatSet         statSet         = Owner.FirstComponentOfType <StatSet>();

            bool isCrit = false;

            float damage = weaponComponent.GenerateAttack(statSet.GetAttackPower(), statSet.GetCritPercent(), ref isCrit);

            r.AddText(((int)damage).ToString(), isCrit);

            healthComponent.TakeDamage(damage);

            SpriterEffect effect = new SpriterEffect(Owner, @"Animations/Splatters");

            effect.Initialize();
            effect.SpriterComponent.Position = target.Position + new Vector2(24f, -38f);

            if (target.ContainsTag("boss"))
            {
                effect.SpriterComponent.Scale = 2.5f;
            }

            effect.SpriterComponent.FlipX = Owner.FirstComponentOfType <FacingComponent>().FacingNumber < 0f;
            effect.SpriterComponent.ChangeAnimation("blood_ribon_0");

            Owner.AddComponent(effect);
        }
示例#16
0
        public void OnAwake()
        {
            _canvas        = SceneObject.Instantiate <Canvas>(Root);
            _log           = _canvas.AddComponent <Text> ();
            _log.Alignment = Alignment.TopLeft;

            Camera.Current = Owner.AddComponent <Camera> ();
            Camera.Current.OnPlayerEntityAssigned += InitCamera;
            Mouse.ShowCursor();

            InitCamera(Camera.Current);
            Program.OnSignal += OnFlowNodeSignal;
        }
示例#17
0
 public override void Initialize()
 {
     base.Initialize();
     Contents = ContainerManagerComponent.Ensure <Container>($"{typeof(EntityStorageComponent).FullName}{Owner.Uid.ToString()}", Owner);
     if (!Owner.TryGetComponent(out StorageComponent))
     {
         StorageComponent = Owner.AddComponent <ServerStorageComponent>();
         // TODO: This is a terrible hack.
         // Components should not need to be manually initialized in Initialize().
         StorageComponent.Initialize();
     }
     entityQuery = new IntersectingEntityQuery(Owner);
 }
示例#18
0
        public override void Initialize()
        {
            base.Initialize();
            Owner.TryGetComponent(out _appearanceComponent);

            if (!Owner.TryGetComponent(out _contents))
            {
                _contents = Owner.AddComponent <SolutionContainerComponent>();
            }

            _contents.Capabilities = SolutionContainerCaps.AddTo | SolutionContainerCaps.RemoveFrom;
            Opened = _defaultToOpened;
            UpdateAppearance();
        }
示例#19
0
        private void SwitchModel()
        {
            Owner.RemoveComponent <Model>();

            index = ++index % 9;

            switch (index)
            {
            case 0:
                Owner.AddComponent(Model.CreateCube());
                break;

            case 1:
                Owner.AddComponent(Model.CreateCone());
                break;

            case 2:
                Owner.AddComponent(Model.CreateTorus());
                break;

            case 3:
                Owner.AddComponent(Model.CreateSphere());
                break;

            case 4:
                Owner.AddComponent(Model.CreatePyramid());
                break;

            case 5:
                Owner.AddComponent(Model.CreateCylinder());
                break;

            case 6:
                Owner.AddComponent(Model.CreateCapsule());
                break;

            case 7:
                Owner.AddComponent(Model.CreateTeapot());
                break;

            case 8:
                Owner.AddComponent(Model.CreatePlane());
                break;

            default:
                throw new InvalidOperationException("Index invalid.");
            }

            Owner.RefreshDependencies();
        }
        private void EquippedBy(int uid, EquipmentSlot wearloc)
        {
            Owner.SendMessage(this, ComponentMessageType.ItemEquipped);
            Owner.AddComponent(ComponentFamily.Mover,
                               Owner.EntityManager.ComponentFactory.GetComponent("SlaveMoverComponent"));
            Owner.SendMessage(this, ComponentMessageType.SlaveAttach, uid);
            switch (wearloc)
            {
            case EquipmentSlot.Back:
                SendDrawDepth(DrawDepth.MobOverAccessoryLayer);
                break;

            case EquipmentSlot.Belt:
                SendDrawDepth(DrawDepth.MobUnderAccessoryLayer);
                break;

            case EquipmentSlot.Ears:
                SendDrawDepth(DrawDepth.MobUnderAccessoryLayer);
                break;

            case EquipmentSlot.Eyes:
                SendDrawDepth(DrawDepth.MobUnderAccessoryLayer);
                break;

            case EquipmentSlot.Feet:
                SendDrawDepth(DrawDepth.MobUnderClothingLayer);
                break;

            case EquipmentSlot.Hands:
                SendDrawDepth(DrawDepth.MobOverAccessoryLayer);
                break;

            case EquipmentSlot.Head:
                SendDrawDepth(DrawDepth.MobOverClothingLayer);
                break;

            case EquipmentSlot.Inner:
                SendDrawDepth(DrawDepth.MobUnderClothingLayer);
                break;

            case EquipmentSlot.Mask:
                SendDrawDepth(DrawDepth.MobUnderAccessoryLayer);
                break;

            case EquipmentSlot.Outer:
                SendDrawDepth(DrawDepth.MobOverClothingLayer);
                break;
            }
        }
示例#21
0
        public override void Initialize()
        {
            base.Initialize();
            _solution ??= Owner.TryGetComponent(out SolutionComponent solutionComponent)
                ? solutionComponent
                : Owner.AddComponent <SolutionComponent>();

            _storage       = ContainerManagerComponent.Ensure <Container>("microwave_entity_container", Owner, out var existed);
            _appearance    = Owner.GetComponent <AppearanceComponent>();
            _powerDevice   = Owner.GetComponent <PowerDeviceComponent>();
            _audioSystem   = _entitySystemManager.GetEntitySystem <AudioSystem>();
            _userInterface = Owner.GetComponent <ServerUserInterfaceComponent>()
                             .GetBoundUserInterface(MicrowaveUiKey.Key);
            _userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
        }
        public override void Initialize()
        {
            base.Initialize();
            Owner.TryGetComponent(out _appearanceComponent);
            if (!Owner.TryGetComponent(out _contents))
            {
                _contents = Owner.AddComponent <SolutionComponent>();
            }

            _contents.Capabilities = SolutionCaps.PourIn
                                     | SolutionCaps.PourOut
                                     | SolutionCaps.Injectable;
            Opened = _defaultToOpened;
            UpdateAppearance();
        }
示例#23
0
        /// <summary>
        /// Called by framework. Do not call directly.
        /// </summary>
        public void OnAwake()
        {
            _unchecked        = Owner.AddComponent <Image> ();
            _unchecked.Source = ResourceManager.ImageFromFile(Application.UIPath + "cb_unchecked.png");
            _checked          = Owner.AddComponent <Image> ();
            _checked.Source   = ResourceManager.ImageFromFile(Application.UIPath + "cb_checked.png");

            _frame = SceneObject.Instantiate <Panel>(Owner);
            _frame.Background.Source       = ResourceManager.ImageFromFile(Application.UIPath + "frame.png", false);
            _frame.Background.SliceType    = SliceType.Nine;
            _frame.Background.Color        = Color.SkyBlue;
            _frame.RectTransform.Alignment = Alignment.Stretch;
            _frame.RectTransform.ClampMode = ClampMode.Full;
            _frame.Active = false;

            IsChecked = true;
        }
示例#24
0
        /// <summary>
        /// Called by framework. Do not call directly.
        /// </summary>
        protected override void OnAwake()
        {
            _unchecked        = Owner.AddComponent <Image>();
            _unchecked.Source = ResourceManager.ImageFromFile(Path.Combine(UIElement.DataDirectory, "cb_unchecked.png"));
            _checked          = Owner.AddComponent <Image>();
            _checked.Source   = ResourceManager.ImageFromFile(Path.Combine(UIElement.DataDirectory, "cb_checked.png"));

            _frame = SceneObject.Instantiate <Panel>(Owner);
            _frame.Background.Source       = ResourceManager.ImageFromFile(Path.Combine(UIElement.DataDirectory, "frame.png"), false);
            _frame.Background.SliceType    = SliceType.Nine;
            _frame.Background.Color        = Color.SkyBlue;
            _frame.RectTransform.Alignment = Alignment.Stretch;
            _frame.RectTransform.ClampMode = ClampMode.Full;
            _frame.Active = false;

            IsChecked = true;
        }
        public override void Initialize()
        {
            base.Initialize();
            if (_contents == null)
            {
                if (Owner.TryGetComponent(out SolutionComponent solutionComponent))
                {
                    _contents = solutionComponent;
                }
                else
                {
                    _contents = Owner.AddComponent <SolutionComponent>();
                }
            }

            _contents.MaxVolume = _initialContents.TotalVolume;
        }
示例#26
0
        /// <summary>
        /// Called by framework. Do not call directly.
        /// </summary>
        protected override void OnAwake()
        {
            _cursor = SceneObject.Instantiate <Panel>(Owner);
            _cursor.Background.Source       = ImageSource.Blank;
            _cursor.RectTransform.Size      = new Point(2, 16);
            _cursor.RectTransform.Alignment = Alignment.Left;
            _cursor.RectTransform.ClampMode = ClampMode.Full;
            _cursor.Background.Source.Texture.RoundLocation = true;
            _cursor.Active = false;

            _frame           = Owner.AddComponent <Image>();
            _frame.Source    = ResourceManager.ImageFromFile(Path.Combine(UIElement.DataDirectory, "frame.png"), false);
            _frame.SliceType = SliceType.Nine;
            _frame.Color     = Color.SkyBlue;
            _frame.Active    = false;

            _text = Owner.GetComponent <Text>();
        }
示例#27
0
        public void SetResources()

        {
            woodAmount = 5000;


            if (isLocalPlayer)
            {
                networkService = (Owner.Scene as NetworkedScene).networkService;
                keysBehavior   = RenderManager.ActiveCamera2D.Owner.FindComponent <KeysBehavior>();
                ui             = UIBehavior.ui;
                map            = Map.map;
                fog            = FogOfWar.fog;
                PathDrawable draw = new PathDrawable();
                draw.SetPlayer(this, path);
                Owner.AddComponent(draw);
            }
        }
示例#28
0
        public void Start(int amount, float duration, float spreadDelay, float removeDelay)
        {
            if (Inception != null)
            {
                return;
            }

            if (Owner.HasComponent <SolutionAreaEffectInceptionComponent>())
            {
                return;
            }

            Amount = amount;
            var inception = Owner.AddComponent <SolutionAreaEffectInceptionComponent>();

            inception.Add(this);
            inception.Setup(amount, duration, spreadDelay, removeDelay);
        }
示例#29
0
        public void ApplyMaterial()
        {
            Owner.RemoveComponent <MaterialsMap>();

            string content = "Content/SmokeParticle.wpk";

            if (currentParticleSystemIndex == 2 ||
                currentParticleSystemIndex == 3)
            {
                content = "Content/WhitePixel.wpk";
            }
            var materials = new MaterialsMap(new BasicMaterial(content, DefaultLayers.Additive)
            {
                VertexColorEnabled = true
            });

            Owner.AddComponent(materials);
        }
示例#30
0
        /// <summary>
        /// Configures the UIAnimation component by adding some generic animations: idle, highlight, click.
        /// </summary>
        /// <param name="idle">Idle animation state.</param>
        /// <param name="highlighted">Highlight animation state.</param>
        /// <param name="clicked">Click animation state.</param>
        /// <param name="toggled">Toggled animation state.</param>
        public void Configure(Animation idle, Animation highlighted, Animation clicked, Animation toggled)
        {
            Idle        = idle;
            Highlighted = highlighted;
            Clicked     = clicked;

            AnimatorComponent = new BasicAnimator();
            AnimatorComponent.AddAnimation("idle", Idle);
            AnimatorComponent.AddAnimation("highlight", Highlighted);
            AnimatorComponent.AddAnimation("click", Clicked);
            if (toggled != null)
            {
                Toggled = toggled;
                AnimatorComponent.AddAnimation("toggle", Toggled);
            }
            Owner.AddComponent(AnimatorComponent);

            AnimatorComponent.Play("idle");
            Configured = true;
        }