Beispiel #1
0
    public void Discover(Ownable owned)
    {
        visibleByList.Add(owned);
        discoveredBy.Add(owned.GetOwner());

        State = EHexState.Visible;
        if (!IsEmpty())
        {
            ObjectInCell.SetActive(true);
        }
        gameObject.GetComponentInChildren <MeshRenderer>().material = VisibleMaterial;
    }
Beispiel #2
0
    public bool Attack(Ownable target)
    {
        if (EventManager.selectionManager.TargetObject != null)
        {
            Debug.Log("weszlo");
            if (target == null || target.GetOwner() == EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>().GetOwner())
            {
                Debug.Log("Cannot find planet or planet belong to you");
                return(false);
            }
            else if (target != null && target.GetOwner() != EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>().GetOwner() && target.GetComponent <Spaceship>() != null)
            {
                if (GetActionPoints() > 0)
                {
                    var heading   = target.transform.position - transform.position;
                    var distance  = heading.magnitude;
                    var direction = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);
                    GameObject SourceFire  = Instantiate(gameApp.AttackPrefab, transform.position + direction, transform.rotation);
                    GameObject SourceFire1 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 2, transform.rotation);
                    GameObject SourceFire2 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 4, transform.rotation);
                    GameObject SourceFire3 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 6, transform.rotation);
                    GameObject SourceFire4 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 8, transform.rotation);
                    heading    = transform.position - target.transform.position;
                    distance   = heading.magnitude;
                    direction  = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);
                    GameObject TargetFire = Instantiate(gameApp.HitPrefab, target.transform.position + direction, target.transform.rotation);
                    target.GetComponent <Spaceship>().AddHealthPoints(-this.spaceshipStatistics.attack);
                    Destroy(SourceFire, 1f);
                    Destroy(SourceFire1, 1.1f);
                    Destroy(SourceFire2, 1.2f);
                    Destroy(SourceFire3, 1.3f);
                    Destroy(SourceFire4, 1.4f);
                    Destroy(TargetFire, 1.5f);
                    return(true);
                }
                Debug.Log("You dont have enough movement points");
                return(false);
            }
            else if (target != null || target.GetOwner() != EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>().GetOwner() &&
                     target.GetComponent <Planet>() != null)
            {
                if (GetActionPoints() > 0)
                {
                    var heading   = target.transform.position - transform.position;
                    var distance  = heading.magnitude;
                    var direction = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);
                    GameObject SourceFire  = Instantiate(gameApp.AttackPrefab, transform.position + direction, transform.rotation);
                    GameObject SourceFire1 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 2, transform.rotation);
                    GameObject SourceFire2 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 4, transform.rotation);
                    GameObject SourceFire3 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 6, transform.rotation);
                    GameObject SourceFire4 = Instantiate(gameApp.AttackPrefab, transform.position + direction * 8, transform.rotation);
                    heading    = transform.position - target.transform.position;
                    distance   = heading.magnitude;
                    direction  = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.5f, 0);
                    GameObject TargetFire = Instantiate(gameApp.HitPrefab, target.transform.position + direction * 2.5f, target.transform.rotation);
                    Destroy(SourceFire, 1f);
                    Destroy(SourceFire1, 1.1f);
                    Destroy(SourceFire2, 1.2f);
                    Destroy(SourceFire3, 1.3f);
                    Destroy(SourceFire4, 1.4f);
                    Destroy(TargetFire, 1.5f);
                    target.GetComponent <Planet>().AddHealthPoints(-this.spaceshipStatistics.attack);
                    return(true);
                }
            }
            Debug.Log("You dont have enough movement points");
            return(false);
        }

        return(false);
    }
Beispiel #3
0
    public bool Attack(Ownable target)
    {
        if (EventManager.selectionManager.TargetObject != null)
        {
            Debug.Log("weszlo");
            if (target == null || target.GetOwner() == EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>().GetOwner())
            {
                Debug.Log("Cannot find planet or planet belong to you");
                return(false);
            }
            else if (target != null && target.GetOwner() != EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>().GetOwner() && target.GetComponent <Spaceship>() != null)
            {
                if (GetActionPoints() > 0)
                {
                    var heading   = target.transform.position - transform.position;
                    var distance  = heading.magnitude;
                    var direction = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);

                    heading    = transform.position - target.transform.position;
                    distance   = heading.magnitude;
                    direction  = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);
                    Quaternion rotation   = Quaternion.LookRotation(heading, Vector3.up);
                    GameObject SourceFire = Instantiate(gameApp.AttackPrefab, transform.position, rotation * Quaternion.Euler(new Vector3(0, 180, 0)));
                    Ownable    newtarget  = target;
                    StartCoroutine(placeExplosion(newtarget.transform.position + direction, rotation));

                    target.GetComponent <Spaceship>().AddHealthPoints(-this.spaceshipStatistics.attack);
                    Destroy(SourceFire, 1.5f);


                    return(true);
                }
                Debug.Log("You dont have enough movement points");
                return(false);
            }
            else if (target != null || target.GetOwner() != EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>().GetOwner() &&
                     target.GetComponent <Planet>() != null)
            {
                if (GetActionPoints() > 0)
                {
                    var heading   = target.transform.position - transform.position;
                    var distance  = heading.magnitude;
                    var direction = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);

                    heading    = transform.position - target.transform.position;
                    distance   = heading.magnitude;
                    direction  = heading / distance; // This is now the normalized direction.
                    direction += new Vector3(0, 0.1f, 0);
                    Quaternion rotation   = Quaternion.LookRotation(heading, Vector3.up);
                    GameObject SourceFire = Instantiate(gameApp.AttackPrefab, transform.position, rotation * Quaternion.Euler(new Vector3(0, 180, 0)));
                    Ownable    newtarget  = target;
                    StartCoroutine(placeExplosion(newtarget.transform.position + direction, rotation));

                    target.GetComponent <Planet>().AddHealthPoints(-this.spaceshipStatistics.attack);
                    Destroy(SourceFire, 1.5f);


                    return(true);
                }
            }
            Debug.Log("You dont have enough movement points");
            return(false);
        }

        return(false);
    }