Beispiel #1
0
    public void InitializeHero()
    {
        if (m_bIsInitialized)
        {
            return;
        }

        m_ActorReference = GetComponent <DynamicActor>();

        m_ActorReference.TurnDelegate           = TakeTurn;
        m_ActorReference.OnActorDied           += Die;
        m_ActorReference.OnActorMoved          += UpdateVisibility;
        m_ActorReference.OnActorMoved          += TickFood;
        m_ActorReference.OnActorInteractedWith += OnInteractedWith;
        TurnBasedManager.s_Instance.AddActor(m_ActorReference);

        m_ActorReference.InitializeActor(EActorType.EAT_Player, "Hero");

        GetComponent <ActorHealthComponent>().SetMaxHealth(
            m_ActorReference.ActorStats.Constitution +
            ResourceLocator.instance.PlayerExtraCon
            );

        OnHeroInitialized?.Invoke();
        m_bIsInitialized = true;
    }
Beispiel #2
0
        internal void OnDynamicActorStreamOut(int actorid, int playerid)
        {
            var actor = DynamicActor.Find(actorid);

            if (actor == null)
            {
                return;
            }
        }
        public DynamicActor GetPlayerCameraTargetActor(BasePlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            return(DynamicActor.Find(Internal.GetPlayerCameraTargetDynActor(player.Id)));
        }
Beispiel #4
0
        internal int OnPlayerGiveDamageDynamicActor(int playerid, int actorid, float amount, int weaponid, int bodypart)
        {
            var args =
                new PlayerShotActorEventArgs(BasePlayer.FindOrCreate(playerid), (Weapon)weaponid, amount, (BodyPart)bodypart);
            var actor = DynamicActor.Find(actorid);

            if (actor != null)
            {
                // evt
            }

            return(0);
        }
Beispiel #5
0
    public void InitializeForCity()
    {
        if (m_bIsInitialized)
        {
            return;
        }

        m_ActorReference = GetComponent <DynamicActor>();
        m_ActorReference.TurnDelegate           = TakeTurn;
        m_ActorReference.OnActorInteractedWith += CityOnInteractedWith;
        m_ActorReference.InitializeActor(EActorType.EAT_Player, "Hero");

        TurnBasedManager.s_Instance.AddActor(m_ActorReference);

        m_bIsInitialized = true;
    }
        private T GetItem <T>(int id) where T : IDynamicWorldObject
        {
            if (typeof(DynamicTextLabel).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicTextLabel.Find(id));
            }

            if (typeof(DynamicPickup).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicPickup.Find(id));
            }

            if (typeof(DynamicRaceCheckpoint).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicRaceCheckpoint.Find(id));
            }

            if (typeof(DynamicObject).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicObject.Find(id));
            }

            if (typeof(DynamicMapIcon).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicMapIcon.Find(id));
            }

            if (typeof(DynamicCheckpoint).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicCheckpoint.Find(id));
            }

            if (typeof(DynamicArea).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicArea.Find(id));
            }

            if (typeof(DynamicActor).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicActor.Find(id));
            }

            throw new Exception("Unknown dynamic world object type.");
        }
Beispiel #7
0
    // TODO: Some way to get all actors around...
    // Add actor to list
    // remove actor from list

    // =================================================================================================
    //
    //  COMBAT
    //
    // =================================================================================================
    #region HANDLING COMBAT
    public void HandleCombat(DynamicActor _AttackingActor, DynamicActor _BeingAttackedActor, Weapon.EWeaponRoll AttackerRoll)
    {
        _AttackingActor.DealtDamage();
        int ExtraStr = 0;

        if (_AttackingActor.ActorType == EActorType.EAT_Player)
        {
            ExtraStr = ResourceLocator.instance.PlayerExtraStr;
        }

        int AttackerModifier = CombatHelpers.CalculateModifier(_AttackingActor.ActorStats.Strength + ExtraStr);

        int Damage = CombatHelpers.CalculateDamage(AttackerModifier, AttackerRoll);

        Damage = Mathf.Max(Damage, 0);

        _BeingAttackedActor.SufferedDamage(Damage);
        Debug.Log($"{_AttackingActor.ActorName} dealt {Damage} damage to {_BeingAttackedActor.ActorName}");
    }
 private void Start()
 {
     m_HeroRef = FindObjectOfType <Hero>().GetComponent <DynamicActor>();
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a <see cref="EnemyPatrol" /> class.
 /// </summary>
 /// <param name="points">The patrolling points.</param>
 /// <param name="enemy">The enemy.</param>
 public void Initialize(Transform[] points, DynamicActor enemy)
 {
     _points = points;
     _enemy  = enemy;
 }
Beispiel #10
0
        /// <summary>
        ///     Raises the <see cref="E:SampSharp.GameMode.BaseMode.Initialized" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data. </param>
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            var vehicle = BaseVehicle.Create(VehicleModelType.Alpha, Vector3.Up * 15, 0, -1, -1);

            vehicle.GetDamageStatus(out var panels, out var doors, out var lights, out var tires);
            Console.WriteLine(panels.ToString());
            Console.WriteLine(doors.ToString());
            Console.WriteLine(lights.ToString());
            Console.WriteLine(tires.ToString());

            var streamer = Services.GetService <IStreamer>();

            Console.WriteLine("Service: " + streamer);

            var area =
                DynamicArea.CreatePolygon(new[]
            {
                Vector3.One + new Vector3(-10, -10),
                Vector3.One + new Vector3(10, -10),
                Vector3.One + new Vector3(10, 10),
                Vector3.One + new Vector3(-10, 10)
            }, -100.0f, 100.0f);

            Console.WriteLine("Area handle: " + area.Id);

            area.Enter += (sender, args) => args.Player.SendClientMessage("Entered polygon");
            area.Leave += (sender, args) => args.Player.SendClientMessage("Left polygon");

            var isValid  = area.IsValid;
            var position = area.Position;
            var points   = area.GetPoints().ToArray();

            Console.WriteLine($"area.IsValid = {isValid}, area.Position = {position}, Points = {string.Join(", ", points)}");

            var area2 = DynamicArea.CreateRectangle(0, 0, 20, 20);

            area2.Enter += (sender, args) => args.Player.SendClientMessage("Entered Rectangle");
            area2.Leave += (sender, args) => args.Player.SendClientMessage("Left Rectangle");

            var icon = new DynamicMapIcon(new Vector3(1500, -1500, 0), Color.Blue, MapIconType.Global, -1, -1, null, 300);

            Console.WriteLine(icon.Position);
            icon.Position = new Vector3(50, 50, 5);
            Console.WriteLine(icon.Position);

            var pickup = new DynamicPickup(1274, 23, new Vector3(0, 0, 3), 100f,
                                           new[] { 11, 22, 33, 44, 0, 55, 66, 77, 88, 99 }); //Dollar icon

            pickup.PickedUp += (sender, args) => args.Player.SendClientMessage(Color.White, "Picked Up");

            var pickup2 = new DynamicPickup(1274, 23, Vector3.One, 42);

            Console.WriteLine("World: {0}", string.Join(",", pickup.Worlds));
            Console.WriteLine("World: {0}", string.Join(",", pickup2.Worlds));

            var checkpoint = new DynamicCheckpoint(new Vector3(10, 10, 3));

            checkpoint.Enter += (sender, args) => args.Player.SendClientMessage(Color.White, "Entered CP");
            checkpoint.Leave += (sender, args) => args.Player.SendClientMessage(Color.White, "Left CP");

            var actor = new DynamicActor(100, new Vector3(20, 10, 5), 0);



            var racecheckpoint = new DynamicRaceCheckpoint(CheckpointType.Normal, new Vector3(-10, -10, 3), new Vector3());

            racecheckpoint.Enter += (sender, args) => args.Player.SendClientMessage(Color.White, "Entered RCP");
            racecheckpoint.Leave += (sender, args) => args.Player.SendClientMessage(Color.White, "Left RCP");

            new DynamicTextLabel("[I am maroon]", Color.Maroon, pickup.Position + new Vector3(0, 0, 1), 100.0f);

            var obj = new DynamicObject(12991, new Vector3(10, 10, 3));

            Console.WriteLine("obj position after spawn " + obj.Position);
            var offset = Vector3.One;

            obj.SetMaterialText(1, "Test", ObjectMaterialSize.X512X512, "Arial", 30, false, Color.Black, Color.White);
            obj.Move(obj.Position + -offset, 0.6f, obj.Rotation + new Vector3(0, 0, 25));
            obj.Moved += (sender, args) =>
            {
                Console.WriteLine("moved");
                obj.Move(obj.Position + (offset = -offset), 0.6f, obj.Rotation + new Vector3(0, 0, 25));
            };


            Console.WriteLine("Test error handling...");
            streamer.IsErrorCallbackEnabled = true;
            streamer.Error += (sender, args) => { Console.WriteLine("Error CB: " + args.Error); };
            streamer.PrintStackTraceOnError = true;
            streamer.ItemType[StreamType.MapIcon].GetArray(9999, StreamerDataType.Color, 1);
            Console.WriteLine("Messages should have appeared above.");
        }
Beispiel #11
0
 private void Awake()
 {
     m_Actor = GetComponent <DynamicActor>();
     m_Actor.InitializeActor(EActorType.EAT_Enemy, MonsterStat.MonsterName);
     GetComponent <ActorHealthComponent>().SetMaxHealth(MonsterStat.HitPoints);
 }
Beispiel #12
0
 protected override void OnInitialize(IActor owner)
 {
     NavMeshAgent = owner.GetGameObject().GetComponent <NavMeshAgent>();
     Player       = new DynamicActor();
 }