Example #1
0
    public void Initialize(int cubeX, int cubeY, HexGrid grid, string name,
                           GameObject mainCanvas, Text textName, Text textHP, ActionExecutor actionExecutor)
    {
        this.coordinates      = new HexCoordinates(cubeX, cubeY);
        this.grid             = grid;
        this.grid.SelectCell += OnCellSelected;         // Bind event
        ownTheCell(getCurrentCell());
        this.moveToCoordinate(this.coordinates.X, this.coordinates.Y);
        this.movingRangeWidth = 2;         // Default moving range
        this.isReadyToMove    = false;
        this.isReadyToAttack  = false;
        this.healthPoint      = 5;
        this.actionPoint      = 3;
        this.attackWidth      = 1;
        this.attackDamage     = 1;
        this.characterName    = name;
        this.moveable         = true;
        this.isSelected       = false;
        this.availableActions = new Dictionary <string, Action> ();
        this.availableActions.Add("移动", new Movement());
        this.availableActions.Add("射击", new InteractiveSkill());
        this.actionExecutor = actionExecutor;

        this.originalCharacter = this;
        if (this.avatarPrefab != null)
        {
            this.avatar = Instantiate(this.avatarPrefab, this.grid.transform, false);
        }
        if (this.avatar != null)
        {
            this.avatar.Initialize(cubeX, cubeY, grid, name, this, mainCanvas, textName,
                                   textHP, actionExecutor);
        }
    }
Example #2
0
    public bool IsPlayerClosest(GameObject source)
    {
        GameObject      gameObject = GetClosestAgent(source);
        AvatarCharacter a          = gameObject.GetComponent <AvatarCharacter>();

        if (a == null)
        {
            return(false);
        }
        return(true);
    }
Example #3
0
 public void RemoveAvatar(AvatarCharacter a)
 {
     if (a.characterType == AvatarCharacter.Character.AI)
     {
         AIPlaying = false;
         aiAvatar.SetActive(false);
     }
     else
     {
         PlayerPlaying = false;
         playerAvatar.SetActive(false);
     }
     //Destroy(a.gameObject);
 }
Example #4
0
    public void Teleport(AvatarCharacter avatarCharacter)
    {
        int r = Random.Range(0, spawnPoints.Count);

        avatarCharacter.gameObject.GetComponent <Rigidbody>().MovePosition(spawnPoints[r].transform.position);
    }
Example #5
0
 public void KillPlayer(AvatarCharacter avatar)
 {
     if (canCapture)
     {
     }
 }