Exemplo n.º 1
0
    public void Init(PlayerSpec spec)
    {
        _spec         = spec;
        _flightVector = new Vector2(0f, -1f);

        SpriteInitialize();
    }
Exemplo n.º 2
0
        public PlayerSpec BuildAiPlayer(string playerName, Guid playerId)
        {
            var childContainer = _container.GetNestedContainer();
            var treeBuilder    = childContainer.GetInstance <TreeBuilder>();
            var fullTree       = childContainer.GetInstance <FullTreeStrategy>();
            var aiTree         =
                treeBuilder.BuildTree <CombineVotes>(fullTree.WithSpec(_treeSpec));
            var aiController = new AiPlayerController(new AiStrategy(aiTree as Function <ResponseVotes>));
            var aiPlayer     = new PlayerSpec().WithPlayerName(playerName).WithController(aiController).WithId(playerId);

            return(aiPlayer);
        }
    // TODO :: 전 씬에서 고른 PlayerType 기억하고 그에 맞추어 Player 생성하기
    private void PlayerCreate()
    {
        var player1Text = Resources.Load <TextAsset>("Data/Archer1").text;
        var player1Spec = PlayerSpec.CreateFromText(player1Text);

        _player1 = Player.Factory.Create(player1Spec);
        _player1.transform.position = CreatePosition();

        //var player2Text = Resources.Load<TextAsset>("Data/Archer1").text;
        //var player2Spec = PlayerSpec.CreateFromText(player2Text);

        //_player2 = Player.Factory.Create(player2Spec);
        //_player2.transform.position = new Vector3(1.0f, 0.0f, 0.0f);
    }
Exemplo n.º 4
0
        public static Player Create(PlayerSpec spec)
        {
            var prefab   = Resources.Load("Prefabs/Player") as GameObject;
            var instance = Instantiate(prefab).GetComponent <Player>();

            if (instance == null)
            {
                Debug.LogErrorFormat("Player Instantiate Failed");
                return(null);
            }

            instance.Init(spec);

            return(instance);
        }
Exemplo n.º 5
0
    public void Init(PlayerSpec spec)
    {
        _beforePosition = transform.position;
        _spec           = spec;
        _spriteRenderer = GetComponent <SpriteRenderer>();
        _animator       = GetComponent <Animator>();
        _hp             = spec._maxHealth;

        SetAnimator(_spec._playerType);
        SetSprite(_spec._playerType);

        FireLineInitialize();
        CrosshairInitialize();

        this.gameObject.AddComponent <PolygonCollider2D>();
    }
    PlayerSpec spec;                                // A handle to the PlayerSpec that we are editing but casted for ease

    /// <summary>
    /// Function called when this editor is enabled
    /// </summary>
    void OnEnable()
    {
        // Setup the SerializedProperties.
        // -- Get the base property
        var specProperty = serializedObject.FindProperty("spec");

        // -- It is an array so we should populate our array with the SerializedProperties
        specProperties = new SerializedProperty[specProperty.arraySize];
        for (int i = 0; i < specProperties.Length; ++i)
        {
            specProperties[i] = specProperty.GetArrayElementAtIndex(i);
        }

        // Get a reference to the object we are editing
        spec = (PlayerSpec)target;
    }
Exemplo n.º 7
0
        private GameSpec MakeGameSpec(Population competitors, Population playersInCurrentGame)
        {
            var spec = new GameSpec().BasicGame().WithSet <FirstGame>();

            _gameSize.Times(() =>
            {
                if (competitors.Any())
                {
                    var competitor = competitors.First();
                    competitors.Remove(competitor);
                    playersInCurrentGame.Add(competitor);
                    var controller = new AiPlayerController(competitor);
                    var playerSpec = new PlayerSpec().WithController(controller).WithId(competitor.Id);
                    spec.WithPlayer(playerSpec);
                }
            });
            return(spec);
        }
Exemplo n.º 8
0
        public static Player Create(PlayerType type)
        {
            // Get Player Spec Struct
            var playerSpecText = Resources.Load <TextAsset>("Data/" + type.ToString()).text;
            var playerSpec     = PlayerSpec.CreateFromText(playerSpecText);

            // Make Player with Spec
            var prefab   = Resources.Load("Prefabs/Player") as GameObject;
            var instance = Instantiate(prefab).GetComponent <Player>();

            if (instance == null)
            {
                Debug.LogError("Player Instantiate Failed");
                return(null);
            }

            instance.Init(playerSpec);

            return(instance);
        }
Exemplo n.º 9
0
    private IEnumerator PlayerCreate()
    {
        // 내 캐릭터 생성.
        var playerSpecText = Resources.Load <TextAsset>("Data/Archer" + (int)_dataContainer._playerType).text;
        var playerSpec     = PlayerSpec.CreateFromText(playerSpecText);

        _player = Player.Factory.Create(playerSpec);
        _player.OnDamageOccured += OnCharacterDamaged;

        // 적 캐릭터 생성.
        var enemySpecText = Resources.Load <TextAsset>("Data/Archer" + (int)_dataContainer._enemyType).text;
        var enemySpec     = PlayerSpec.CreateFromText(enemySpecText);

        _enemy = Player.Factory.Create(enemySpec);
        _enemy.OnDamageOccured += OnCharacterDamaged;
        _enemy.SetEnemy();

        // 이펙트 매니저에서 쓸 수 있도록 등록.
        _effectManager.SetPlayers(_player.gameObject, _enemy.gameObject);
        yield break;
    }
Exemplo n.º 10
0
    private void PlayerCreate()
    {
        // 내 캐릭터 생성.
        var playerSpecText = Resources.Load <TextAsset>("Data/Archer1").text;
        var playerSpec     = PlayerSpec.CreateFromText(playerSpecText);

        _player           = Player.Factory.Create(playerSpec);
        _player._isMyTurn = true;

        // 적 캐릭터 생성.
        var enemySpecText = Resources.Load <TextAsset>("Data/Archer2").text;
        var enemySpec     = PlayerSpec.CreateFromText(enemySpecText);

        _enemy = Player.Factory.Create(enemySpec);
        _enemy.SetEnemy();

        var playerPosition = Camera.main.ScreenToWorldPoint(new Vector3(50, 300, 0));

        playerPosition.z           = 10;
        _player.transform.position = playerPosition;

        DataContainer.GetInstance().SetPlayerPosition(_player.transform.position);
        DataContainer.GetInstance().SetEnemyPosition(_enemy.transform.position);
    }