Пример #1
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.EquiptmentManager.AddDefaultItem(new Trousers());
        LoadedPlayer = loadedEntity;


        if (TestMain.TEST_MODE)
        {
        }
        else
        {
        }
    }
Пример #2
0
    /// <summary>
    /// Called by all position target setters. Ensures that the position set
    /// is within the current path finding bounds. <br/>If the point is outside the map,
    /// we find the nearest point and set as the target, whilst saving the final target position.
    /// We then pass this final target position
    /// </summary>
    /// <param name="target"></param>
    private void InternalSetTargetPosition(Vector3 target)
    {
        if (target == Vector3.zero)
        {
            Debug.Log("set target to 0");
        }
        Debug.Log(LoadedEntity.Entity + " again");
        //Ensure target is set
        Target = target;
        //Find the neasest node
        NNInfo nninfo = AstarPath.active.GetNearest(target);

        //If the node is far from the target position, we ensure that the path finder knows
        //that this is not the final position.
        if ((target - nninfo.position).XZ().sqrMagnitude > 4)
        {
            IsExactTarget = false;
            TargetObject.transform.position = nninfo.position;
            //Debug.Log(LoadedEntity.Entity + " has non exact PF: " + nninfo.position + "->" + target);
        }
        else
        {
            IsExactTarget = true;
            TargetObject.transform.position = target;
            //Debug.Log(LoadedEntity.Entity + " has exact PF: " + target);
        }
        LoadedEntity.SetLookBasedOnMovement(true);

        LoadedEntity.SetIdle(false);
    }