/// <summary>
    /// Called by unity engine when projectile collides with another object.
    /// Triggers <see cref="Projectile.InternalOnCollision(Collision)"/>
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "MainCamera")
        {
            return;
        }
        if (Source != null)
        {
            LoadedEntity LoadedEntity = other.gameObject.GetComponent <LoadedEntity>();
            if (LoadedEntity == null)
            {
                LoadedEntity = other.gameObject.GetComponentInParent <LoadedEntity>();
            }
            if (LoadedEntity != null)
            {
                if (LoadedEntity.Entity.Equals(Source))
                {
                    return;
                }
            }
        }
        Projectile.InternalOnCollision(other);

        if (Projectile.DestroyOnCollision)
        {
            SpellManager.Instance.DestroyProjectile(this);
        }
    }
Example #2
0
    public void SetPlayer(Player player)
    {
        GameObject entityObject = Instantiate(player.GetEntityGameObject());

        entityObject.name             = "Player";
        entityObject.transform.parent = transform;

        LoadedEntity loadedEntity = entityObject.GetComponent <LoadedEntity>();

        player.OnEntityLoad(loadedEntity, true);
        loadedEntity.SetEntity(player);
        entityObject.transform.position = player.Position;
        loadedEntity.SetLookBasedOnMovement(false);
        Player = player;
        //Player.CombatManager.AddSpell(new SpellFireball(), 0);
        //Player.CombatManager.SpellManager.AddSpell(new SpellStoneWall(), 0);


        Player.Inventory.AddItem(new SteelLongSword());
        Player.Inventory.AddItem(new SimpleDungeonKey(0));
        //Player.Inventory.AddItem(new SteelLegs());
        Player.EquiptmentManager.AddDefaultItem(new Trousers());
        Player.EquiptmentManager.AddDefaultItem(new Shirt());

        Player.CombatManager.EntitySpellManager.AddSpell(new SpellFireball());
        Player.CombatManager.EntitySpellManager.AddSpell(new SpellFireBreath());

        // Player.EquiptmentManager.AddDefaultItem(new Trousers());
        LoadedPlayer = loadedEntity;

        GetComponent <ProceduralGridMover>().target = Player.GetLoadedEntity().transform;
    }
Example #3
0
 public void UnloadEntity(bool player = false)
 {
     LoadedEntity = null;
     if (!player)
     {
         EntityAI.OnEntityUnload();
     }
 }
Example #4
0
 public void OnEntityLoad(LoadedEntity e, bool player = false)
 {
     LoadedEntity = e;
     if (!player)
     {
         EntityAI.OnEntityLoad();
     }
 }
Example #5
0
    public override void InternalOnCollision(Collider other)
    {
        LoadedEntity le = other.gameObject.GetComponent <LoadedEntity>();

        if (le != null)
        {
            le.Entity.CombatManager.DealDamage(DPS * Time.deltaTime, DamageType.FIRE);
        }
    }
Example #6
0
    public static Entity GetHitEntity(Collider col)
    {
        LoadedEntity LoadedEntity = col.gameObject.GetComponent <LoadedEntity>();

        if (LoadedEntity == null)
        {
            LoadedEntity = col.gameObject.GetComponentInParent <LoadedEntity>();
        }

        if (LoadedEntity == null)
        {
            return(null);
        }
        return(LoadedEntity.Entity);
    }
Example #7
0
    public void LoadEntity(Entity entity)
    {
        GameObject entityObject = Instantiate(entity.GetEntityGameObject());

        entityObject.name             = entity.Name;
        entityObject.transform.parent = transform;

        LoadedEntity loadedEntity = entityObject.GetComponent <LoadedEntity>();

        loadedEntity.SetEntity(entity);
        entity.OnEntityLoad(loadedEntity);
        LoadedEntities.Add(loadedEntity);

        if (entity is NPC)
        {
            Debug.Log("Loading " + entity.Name + " from chunk " + World.GetChunkPosition(entity.Position), Debug.ENTITY_TEST);
        }
    }
Example #8
0
    private void Awake()
    {
        LoadedEntity                         = GetComponent <LoadedEntity>();
        AIPathFinder                         = gameObject.AddComponent <AIPath>();
        DestinationSetter                    = gameObject.AddComponent <AIDestinationSetter>();
        TargetObject                         = new GameObject();
        TargetObject.transform.parent        = PathFinderTargetHolder.Holder;
        TargetObject.transform.localPosition = new Vector3(float.MaxValue, float.MaxValue);
        DestinationSetter.target             = TargetObject.transform;

        Target = LoadedEntity.transform.position;

        AIPathFinder.radius = 0.4f;

        //StartCoroutine(WaitThenConstrain(1));
        //AIPathFinder.constrainInsideGraph = true;
        AIPathFinder.updateRotation = true;
        RB = LoadedEntity.gameObject.GetComponent <Rigidbody>();
    }
Example #9
0
    public void UnloadEntity(LoadedEntity e, bool autoRemove = true)
    {
        if (autoRemove)
        {
            LoadedEntities.Remove(e);
        }



        GameManager.EventManager.RemoveListener(e.Entity.CombatManager);
        GameManager.EventManager.RemoveListener(e.Entity.GetLoadedEntity());
        e.Entity.EntityAI.OnEntityUnload();

        if (e.Entity.IsFixed)
        {
            AddFixedEntity(e.Entity);
        }


        Destroy(e.gameObject);
        GameManager.EventManager.RemoveListener(e);
    }
Example #10
0
    private void OnCollisionEnter(Collision collision)
    {
        //We only check for damage collision if we are currently swining this weapon
        if (!IsSwinging)
        {
            return;
        }
        //Check if the object we collide with is an entity
        LoadedEntity le = collision.gameObject.GetComponent <LoadedEntity>();

        if (le == null)
        {
            return;
        }


        if (le.Entity == Entity)
        {
            return;
        }

        le.Entity.CombatManager.DealDamage(SwingDamage, DamageType, Entity);
    }
Example #11
0
    public void RightMouseButton()
    {
        if (LookObject != null)
        {
            LoadedEntity lEnt = LookObject.GetComponent <LoadedEntity>();
            if (lEnt != null)
            {
                Entity ent = lEnt.Entity;
                if (ent is NPC)
                {
                    NPC npc = ent as NPC;

                    if (npc.HasDialog())
                    {
                        StartDialog(npc);
                    }
                }
            }
        }
        return;

        Ray  ray       = PlayerCamera.ScreenPointToRay(Input.mousePosition);
        bool entSelect = false;

        Debug.Log("hmmm");
        RaycastHit[] raycasthit = Physics.RaycastAll(ray);
        foreach (RaycastHit hit in raycasthit)
        {
            Debug.Log(hit);
            LoadedEntity hitEnt = hit.transform.gameObject.GetComponent <LoadedEntity>();
            if (hitEnt != null)
            {
                entSelect = true;
                //GameManager.DebugGUI.SetSelectedEntity(hitEnt);
                Entity hitEntity = hitEnt.Entity;
                if (hitEntity is NPC)
                {
                    NPC npc = hitEntity as NPC;
                    //If we have selected a different entities
                    if (npc != CurrentlySelected)
                    {
                        Debug.Log(hitEntity.Name + " has been clicked by the player");
                        GameManager.EventManager.InvokeNewEvent(new PlayerTalkToNPC(npc));
                        CurrentlySelected = npc;

                        if (npc.HasDialog())
                        {
                            Debug.Log("TRUE DIALOG");
                            GameManager.GUIManager.StartDialog(npc);
                            if (!Player.InConversation())
                            {
                                if (Player.CurrentDialogNPC() != npc)
                                {
                                    NPCDialog dial = npc.Dialog;
                                    dial.StartDialog();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                CurrentlySelected = null;
            }
            Debug.Log(hit.collider.gameObject);
            if (hit.collider.gameObject.GetComponent <WorldObject>() != null)
            {
                WorldObject obj = hit.collider.gameObject.GetComponent <WorldObject>();
                Debug.Log(obj);
                Debug.Log(obj.Data);
                if (obj.Data is IOnEntityInteract)
                {
                    Debug.Log("here2");
                    (obj.Data as IOnEntityInteract).OnEntityInteract(Player);
                }
            }
        }

        if (!entSelect)
        {
            GameManager.DebugGUI.SetSelectedEntity(null);
        }
    }
 public Task <TDto> GetDtoAsync() => LoadedEntity.GetDtoAsync();
 private void OnEnable()
 {
     // SMR = GetComponentInChildren<SkinnedMeshRenderer>();
     LoadedEntity  = GetComponent <LoadedEntity>();
     EquiptObjects = new Dictionary <LoadedEquiptmentPlacement, GameObject>();
 }
 protected virtual void Awake()
 {
     LoadedEntity = GetComponent <LoadedEntity>();
     Animator     = GetComponent <Animator>();
     EventManager.Instance.AddListener(this);
 }
Example #15
0
 public void SetSelectedEntity(LoadedEntity e)
 {
     SelectedEntity = e;
 }