示例#1
0
    /// <summary>
    /// Start of spell checks if target position is existing wall object, if it is we
    /// define this as our wall, and continue to build on it
    /// </summary>
    /// <param name="data"></param>
    public override void SpellStart(SpellCastData data)
    {
        if (!IsPointFree(data.Target))
        {
            return;
        }
        //Get objects in raycast of spell
        Vector3 disp = data.Target - data.Source.GetLoadedEntity().transform.position;

        RaycastHit[] hit = Physics.RaycastAll(data.Source.GetLoadedEntity().transform.position, disp, disp.magnitude);
        //iterate all objects hit by the spell ray
        foreach (RaycastHit hit_ in hit)
        {
            MarchingCubesStoneWall hit_wall = hit_.collider.gameObject.GetComponent <MarchingCubesStoneWall>();
            //If the hit object is a valid wall
            if (hit_wall != null)
            {
                //Then set the wall here to that wall, and buid onto it
                mcw = hit_wall;
                mcw.BuildWall(data.Target);
                return;
            }
        }
        //If no wall in the way, create a new one
        GameObject obj = GameManager.WorldManager.ForceInstanse(ResourceManager.GetMiscPrefab("march_sone_wall"));

        mcw = obj.GetComponent <MarchingCubesStoneWall>();
        mcw.Initiate(data.Target);
        mcw.BuildWall(data.Target);
        IsCast = true;
    }
示例#2
0
 public override void SpellUpdate(SpellCastData data)
 {
     if (LoadedSpell != null && IsCast)
     {
         LoadedSpell.UpdateTarget(data.Target);
     }
 }
示例#3
0
    public override void SpellStart(SpellCastData data)
    {
        Beam beam = new BeamFireBreath(this);

        LoadedSpell = SpellManager.Instance.CreateNewBeam(data.Source, beam, data.Target);
        IsCast      = true;
    }
示例#4
0
 /// <summary>
 /// Checks if the target position for spell is valid
 /// i.e. - the position has no entity or world object in it
 /// </summary>
 /// <param name="data"></param>
 public override void SpellUpdate(SpellCastData data)
 {
     if (IsPointFree(data.Target))
     {
         //Add target point to wall
         mcw.BuildWall(data.Target);
     }
 }
示例#5
0
    public override void CastSpell(SpellCastData data)
    {
        Vector2 look = new Vector2(Mathf.Cos(data.Source.LookAngle * Mathf.Deg2Rad), -Mathf.Sin(data.Source.LookAngle * Mathf.Deg2Rad));

        Vector3 direction = Quaternion.Euler(data.Target - data.SpellSource) * Vector3.forward;

        SpellManager.Instance.AddNewProjectile(data.Source.Position + Vector3.up * 0.8f, direction, new FireBall(), data.Source);
        //GameManager.WorldManager.AddNewProjectile(data.Source.Position + Vector3.up * 0.8f, look, new FireBall(), data.Source);
    }
示例#6
0
        public static void HandleSpellStart(ParsingContext context, Packet packet)
        {
            var castData = new SpellCastData(packet);

            var subscription = context.SpellHistory.Register(castData.CastGUID, castData.Caster, castData.UnitCaster, castData.SpellID).Subscribe(historyEntry =>
            {
                historyEntry.SpellStart = packet.Moment;
            });

            context.RegisterResource(subscription);
        }
示例#7
0
    /// <summary>
    /// Called for a loaded entity that can cast spells
    /// Checks if the Entity is currently casting a Continous Cast spell
    /// If they are, we update the spell casting, and change mana and XP values
    /// accordingly
    /// </summary>
    /// <param name="data"></param>
    public void Update(SpellCastData data)
    {
        //Check lots 1 and 2
        for (int i = 0; i < 2; i++)
        {
            //get the spell, continue if spell is null
            Spell s = EquiptSpells[i];
            if (s == null)
            {
                continue;
            }
            //If the spell is a hold spell
            if (s is HoldSpell)
            {
                HoldSpell holdSpell = s as HoldSpell;

                if (holdSpell.IsCast)
                {
                    //Check if the key is down
                    if (SpellKeyDown[i] == false)
                    {
                        holdSpell.SpellEnd(data); //If not, then end the spell
                        Debug.Log("Ending");
                    }
                    else
                    {
                        //Set to false to be updated
                        SpellKeyDown[i] = false;
                        //If we have enough mana, update the spell
                        if (CurrentMana > holdSpell.ManaCost * Time.deltaTime)
                        {
                            Debug.Log("Updating");
                            holdSpell.SpellUpdate(data);
                            AddXp(holdSpell);
                            CurrentMana -= holdSpell.ManaCost * Time.deltaTime;
                        }
                        else
                        {
                            Debug.Log("Ending");

                            //If not, stop the spell
                            holdSpell.SpellEnd(data);
                        }
                    }
                }
            }
        }
    }
示例#8
0
    public override void Update()
    {
        Vec2i cPos = World.GetChunkPosition(Position);

        if (cPos != LastChunkPosition)
        {
            GameManager.EntityManager.UpdateEntityChunk(this, LastChunkPosition, cPos);
            LastChunkPosition = cPos;
        }

        SpellCastData data = new SpellCastData();

        data.Source = this;
        data.Target = GameManager.PlayerManager.GetWorldMousePosition();
        CombatManager.SpellManager.Update(data);
    }
示例#9
0
    public override void Update()
    {
        Debug.BeginDeepProfile("player_update_main");
        Vec2i cPos = World.GetChunkPosition(Position);

        if (cPos != LastChunkPosition)
        {
            EntityManager.Instance.UpdateEntityChunk(this, LastChunkPosition, cPos);
            LastChunkPosition = cPos;
        }
        Debug.EndDeepProfile("player_update_main");

        SpellCastData data = new SpellCastData();

        data.Source = this;
        data.Target = PlayerManager.Instance.GetWorldMousePosition();
        CombatManager.EntitySpellManager.Update(data);
    }
示例#10
0
        public void DisarmEveryoneLmao()
        {
            SpellCastData lightningData = Player.currentCreature.mana.casterLeft.spellInstance is SpellCastLightning
                ? Player.currentCreature.mana.casterLeft.spellInstance
                : Player.currentCreature.mana.casterRight.spellInstance;

            if (lightningData is SpellCastLightning cast)
            {
                // modified from ThunderRoad source code for Gravity crystal slam
                List <Creature> pushedCreatures = new List <Creature>();
                foreach (Collider collider in Physics.OverlapSphere(Player.currentCreature.mana.mergePoint.position, radius)
                         .Where(c =>
                                c.attachedRigidbody &&
                                c.attachedRigidbody &&
                                !c.attachedRigidbody.isKinematic))
                {
                    if (collider.attachedRigidbody.gameObject.layer == GameManager.GetLayer(LayerName.NPC) || collider.attachedRigidbody.gameObject.layer == GameManager.GetLayer(LayerName.Ragdoll))
                    {
                        RagdollPart component = collider.attachedRigidbody.gameObject.GetComponent <RagdollPart>();
                        if (component.ragdoll.creature == Player.currentCreature)
                        {
                            continue;
                        }
                        if (component && !pushedCreatures.Contains(component.ragdoll.creature))
                        {
                            // do it again, just in case lmao
                            pushedCreatures.Add(component.ragdoll.creature);
                            component.ragdoll.creature.handLeft.TryRelease();
                            component.ragdoll.creature.handRight.TryRelease();
                            ActionShock action = component.ragdoll.creature.brain.GetAction <ActionShock>();
                            if (action != null)
                            {
                                action.Refresh(0.5f, cast.boltShockDuration);
                            }
                            else
                            {
                                ActionShock actionShock = new ActionShock(0.5f, cast.boltShockDuration, imbueRagdollEffect);
                                component.ragdoll.creature.brain.TryAction(actionShock, true);
                            }
                        }
                    }
                }
            }
        }
示例#11
0
    /// <summary>
    /// Casts the specified spell from the local spell inventory
    /// based on the relevent SpellCastData
    /// </summary>
    /// <param name="spell"></param>
    /// <param name="data"></param>
    public void CastSpell(int spell, SpellCastData data)
    {
        //Check if spell number is valid
        if (spell <= 0 && spell < 2)
        {
            SpellKeyDown[spell] = true; //Set the hold figure to tue

            Spell s = EquiptSpells[spell];
            if (s == null)
            {
                return;
            }
            if (s is SingleSpell)
            {
                Debug.Log("single spell");
                //If the spell is a single cast, ensure the cool down and mana costs are valid.
                SingleSpell singSpe = s as SingleSpell;
                if (CurrentMana > s.ManaCost && SpellTimers[spell].ElapsedMilliseconds > singSpe.CoolDown * 1000)
                {
                    singSpe.CastSpell(data);
                    AddXp(s);
                    CurrentMana -= s.ManaCost;
                    SpellTimers[spell].Restart();
                }
                else
                {
                    Debug.Log("Cur man/Cost: " + CurrentMana + "/" + s.ManaCost + " elapsed/cooldown: " + SpellTimers[spell].ElapsedMilliseconds + "/" + singSpe.CoolDown * 1000);
                }
            }
            else
            {
                //If the spell is a hold spell, check if we've started casting it.
                HoldSpell holdSpel = s as HoldSpell;
                if (!holdSpel.IsCast)
                {
                    Debug.Log("Casting");
                    holdSpel.SpellStart(data);
                    AddXp(s);
                    CurrentMana -= s.ManaCost * Time.deltaTime;
                }
                //If we are casting, it is dealth with in the u[
            }
        }
    }
示例#12
0
        public static void HandleSpellGo(ParsingContext context, Packet packet)
        {
            var spellCastData = new SpellCastData(packet);

            // Delayed subscription because we need to wait for SMSG_SPELL_START to be processed.
            var subscription = context.SpellHistory[spellCastData.CastGUID].Subscribe(historyEntry =>
            {
                // Debug.Assert(historyEntry.SpellID == spellCastData.SpellID, "Spell ID mismatch!");
                // Debug.Assert(historyEntry.Caster == spellCastData.Caster, "Caster GUID mismatch");
                // Debug.Assert(historyEntry.UnitCaster == spellCastData.UnitCaster, "Unit caster GUID mismatch!");

                historyEntry.HitTargets    = spellCastData.HitTargets;
                historyEntry.MissedTargets = spellCastData.MissedTargets;

                historyEntry.ExplicitTarget = spellCastData.ExplicitTarget;

                historyEntry.SpellGo = packet.Moment;
            });

            context.RegisterResource(subscription);
        }
示例#13
0
 /// <summary>
 /// Called if the left mouse button pressed
 /// </summary>
 public void LeftMouseButton()
 {
     //Weapon in sheath but not in hand, so we put in hand
     if (Player.EquiptmentManager.HasWeapon && !Player.EquiptmentManager.WeaponReady)
     {
         Debug.Log("Unsheeth");
         Player.EquiptmentManager.UnsheathWeapon(LoadedEquiptmentPlacement.weaponSheath);
         return;
     }
     else if (Player.EquiptmentManager.HasWeapon && Player.CombatManager.CanAttack())
     {
         Debug.Log("is ready");
         Player.CombatManager.UseEquiptWeapon();
     }
     else if (Player.CombatManager.EntitySpellManager.HasEquiptSpell(LoadedEquiptmentPlacement.weaponHand))
     {
         Debug.Log("Using spell");
         SpellCastData scd = new SpellCastData();
         scd.Source      = Player;
         scd.SpellSource = Player.GetLoadedEntity().transform.position + Vector3.up * 1.5f;
         scd.Target      = GetWorldMousePosition();
         Player.CombatManager.EntitySpellManager.CastSpell(0, scd);
     }
 }
示例#14
0
    void Update()
    {
        if (Console.Instance != null && Console.Instance.Active)
        {
            return;
        }


        if (GameManager.GUIManager != null && GameManager.GUIManager.DialogGUI.InConversation)
        {
            return;
        }


        if (Input.GetKeyDown(KeyCode.P))
        {
            doPath = true;
        }
        else
        {
            doPath = false;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            GUIManager2.Instance.SetVisible(!GUIManager2.Instance.OpenGUIVisible);
        }

        if (GameManager.Paused)
        {
            return;
        }

        Debug.BeginDeepProfile("PlayerManagerUpdate");

        Vector3 worldMousePos = GetWorldMousePosition();

        Tick(Time.deltaTime);


        Player.Update();

        MovementUpdate();

        PlayerSelectUpdate();

        /*
         * float x = Input.GetAxis("Horizontal");
         * float z = Input.GetAxis("Vertical");
         *
         *
         * float ud = x * Mathf.Cos(-PlayerCameraScript.Theta * Mathf.Deg2Rad) + z * Mathf.Sin(-PlayerCameraScript.Theta * Mathf.Deg2Rad);
         * float lr = x * Mathf.Sin(-PlayerCameraScript.Theta * Mathf.Deg2Rad) - z * Mathf.Cos(-PlayerCameraScript.Theta * Mathf.Deg2Rad);
         *
         * x *= Mathf.Cos(PlayerCameraScript.Theta * Mathf.Deg2Rad) + Mathf.Sin(PlayerCameraScript.Theta * Mathf.Deg2Rad);
         * z *= Mathf.Sin(PlayerCameraScript.Theta * Mathf.Deg2Rad);
         *
         * LoadedPlayer.MoveInDirection(new Vector2(lr, ud));
         *
         */


        GameManager.DebugGUI.SetData("world_mouse_pos", worldMousePos.ToString());
        LoadedPlayer.LookTowardsPoint(worldMousePos);

        if (Input.GetKey(KeyCode.Alpha1))
        {
            SpellCastData data = new SpellCastData();
            data.Source = Player;
            data.Target = GetWorldMousePosition();
            Player.CombatManager.SpellManager.CastSpell(0, data);
        }

        if (Input.GetMouseButtonDown(0))
        {
            LeftMouseButton();
        }
        else if (Input.GetMouseButtonDown(1))
        {
            RightMouseButton();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            LoadedPlayer.Jump();
        }

        LoadedPlayer.SetRunning(Input.GetKey(KeyCode.LeftShift));

        Debug.EndDeepProfile("PlayerManagerUpdate");
    }
示例#15
0
 public override void SpellEnd(SpellCastData data)
 {
     GameManager.WorldManager.DestroyBeam(LoadedSpell);
     IsCast = false;
 }
示例#16
0
 public override void SpellEnd(SpellCastData data)
 {
     //For this spell, we shouldn't need to do anything...
     IsCast = false;
 }
示例#17
0
    public override void CastSpell(SpellCastData data)
    {
        Vector2 look = new Vector2(Mathf.Cos(data.Source.LookAngle * Mathf.Deg2Rad), -Mathf.Sin(data.Source.LookAngle * Mathf.Deg2Rad));

        GameManager.WorldManager.AddNewProjectile(data.Source.Position + Vector3.up * 0.8f, look, new FireBall(), data.Source);
    }
示例#18
0
 public abstract void SpellUpdate(SpellCastData data);
示例#19
0
 public abstract void CastSpell(SpellCastData data);
示例#20
0
 public abstract void SpellStart(SpellCastData data);
示例#21
0
 public override void SpellEnd(SpellCastData data)
 {
     SpellManager.Instance.DestroyBeam(LoadedSpell);
     IsCast = false;
 }
示例#22
0
 public abstract void SpellEnd(SpellCastData data);
示例#23
0
    void Update()
    {
        LoadedPlayer.SetIdle(false);
        if (Console.Instance != null && Console.Instance.Active)
        {
            return;
        }



        if (GUIManager.Instance != null && GUIManager.Instance.DialogGUI.InConversation)
        {
            Debug.Log(GUIManager.Instance.DialogGUI.InConversation);
            Debug.Log("Caused by GUI = true");
            return;
        }



        if (Input.GetKeyDown(KeyCode.P))
        {
            doPath = true;
        }
        else
        {
            doPath = false;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            GUIManager.Instance.SetVisible(!GUIManager.Instance.OpenGUIVisible);
        }

        if (GameManager.Paused)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (PlayerCameraScript.CameraController is FirstPersonCC)
            {
                PlayerCameraScript.SetThirdPersonCamera();
            }
            else
            {
                PlayerCameraScript.SetFirstPersonCamera();
            }
        }
        // Debug.BeginDeepProfile("PlayerManagerUpdate");

        Vector3 worldMousePos = GetWorldMousePosition();


        Vec2i currentChunk = World.GetChunkPosition(Player.TilePos);

        if (currentChunk != LastChunk)
        {
            LastChunk = currentChunk;
        }
        Tick(Time.deltaTime);
        Player.Update();

        MovementUpdate();
        PlayerSelectUpdate();



        DebugGUI.Instance.SetData("world_mouse_pos", worldMousePos.ToString());
        LoadedPlayer.LookTowardsPoint(worldMousePos);

        if (Input.GetKey(KeyCode.Alpha1))
        {
            SpellCastData data = new SpellCastData();
            data.Source = Player;
            data.Target = GetWorldMousePosition();
            Player.CombatManager.EntitySpellManager.CastSpell(0, data);
        }

        if (Input.GetMouseButton(0))
        {
            LeftMouseButton();
        }
        else if (Input.GetMouseButtonDown(1))
        {
            RightMouseButton();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            LoadedPlayer.Jump();
        }

        LoadedPlayer.SetRunning(Input.GetKey(KeyCode.LeftShift));

        Debug.EndDeepProfile("PlayerManagerUpdate");
    }