Exemplo n.º 1
0
    internal void OnSelectHaggis(HaggisBehaviour haggisBehaviour, RaycastHit hitInfo)
    {
        Debug.LogFormat("Haggis Selected would have performed action : {0}", currentSelectedAction);
        if (haggisBehaviour.currentAction == HaggisBehaviour.Action.Walking)
        {
            switch (currentSelectedAction)
            {
            case HaggisBehaviour.Action.Blocking:
                haggisBehaviour.SetCurrentAction(HaggisBehaviour.Action.Blocking);
                break;

            case HaggisBehaviour.Action.Building:
                haggisBehaviour.actionsRemaining = haggisBehaviour.numberOfBricks;
                haggisBehaviour.StartBuilding();
                haggisBehaviour.SetCurrentAction(HaggisBehaviour.Action.Building);
                break;

            case HaggisBehaviour.Action.Bombing:
                haggisBehaviour.SetCurrentAction(HaggisBehaviour.Action.Bombing);
                break;
            }
        }
        else if (currentSelectedAction == HaggisBehaviour.Action.Bombing)
        {
            haggisBehaviour.SetCurrentAction(HaggisBehaviour.Action.Bombing);
        }
    }
 public void DoStepOn(HaggisBehaviour haggisBehaviour)
 {
     HaggisCommand[] commands = GetComponents <HaggisCommand>();
     foreach (HaggisCommand command in commands)
     {
         command.DoStepOn(haggisBehaviour);
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        HaggisBehaviour hb = other.GetComponent <HaggisBehaviour>();

        if (hb)
        {
            hb.DoSave();
        }
    }
Exemplo n.º 4
0
    internal void SaveHaggis(HaggisBehaviour haggisBehaviour)
    {
        Debug.Log("Bye Bye");
        this.haggisSaved++;
        GameObject t = haggisBehaviour.gameObject;

        t.SetActive(false);        // destroy self
        SetActiveAllChildren(t.transform, false);
    }
    void SpawnHaggis()
    {
        GameObject      go = haggisActionController.InstantiateHaggis(transform);
        HaggisBehaviour hb = go.GetComponent <HaggisBehaviour>();

        if (hb)
        {
            hb.setActionController(haggisActionController);
        }
    }
Exemplo n.º 6
0
    private IEnumerator DoBuild(Transform transform)
    {
        Transform go = Instantiate(BuildStepBlock, transform.position, transform.rotation);

        yield return(new WaitForSeconds(3));

        HaggisBehaviour hb = GetComponent <HaggisBehaviour>();

        hb.SetCurrentAction(HaggisBehaviour.Action.Walking);
    }
Exemplo n.º 7
0
 public void DestroyAll()
 {
     foreach (GameObject haggis in haggisPool.objects)
     {
         if (haggis.activeInHierarchy)
         {
             HaggisBehaviour hb = haggis.GetComponent <HaggisBehaviour>();
             hb.SetCurrentAction(HaggisBehaviour.Action.Bombing);
         }
     }
 }
Exemplo n.º 8
0
    public GameObject InstantiateHaggis(Transform location)
    {
        GameObject      go = haggisPool.Pop();
        HaggisBehaviour bh = go.GetComponent <HaggisBehaviour>();

        bh.setActionController(this);
        this.haggisSpawned++;
        //GameObject go = Instantiate(haggisPreFab);
        go.transform.position = location.position;
        go.transform.rotation = location.rotation;
        go.SetActive(true);
        return(go);
    }
Exemplo n.º 9
0
    private void DoExplode()
    {
        Collider[] objects = Physics.OverlapSphere(transform.position, explosionRadius);

        foreach (Collider obj in objects)
        {
            HaggisBehaviour hb = obj.GetComponent <HaggisBehaviour>();
            if (hb)
            {
                //hb.rigidBody.AddExplosionForce(explosionForce, transform.position, explosionRadius, 5.0f);
                Vector3 dir = hb.transform.position - transform.position;
                dir.Normalize();
                hb.rigidBody.AddForce(dir * explosionForce, ForceMode.Impulse);
            }

            HaggisExplodable he = obj.GetComponent <HaggisExplodable>();
            if (he)
            {
                he.Detonate();
            }
        }
        DoDie();
    }
Exemplo n.º 10
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Start Called");
        rend         = GetComponent <Renderer>();
        rend.enabled = true;

        behaviour = GetComponent <HaggisBehaviour>();
        behaviour.AddOnActionEnter(func: OnActionEnter);

        rigidBody = GetComponent <Rigidbody>();
        rigidBody.maxAngularVelocity = 0.0f;

        /*ParticleSystem [] particleEffects = GetComponentsInChildren<ParticleSystem>(true);
         * foreach(ParticleSystem p in particleEffects)
         * {
         *  if (p.CompareTag("Explosion"))
         *      explosionEffect = p;
         * }
         *
         * if (explosionEffect)
         *  explosionEffect.Stop();
         * else
         *  Debug.LogError("ExplosionEffect not found!"); */
    }
Exemplo n.º 11
0
 public override void DoStepOn(HaggisBehaviour haggisBehaviour)
 {
     haggisBehaviour.DoDie();
 }
Exemplo n.º 12
0
 public virtual void DoStepOn(HaggisBehaviour haggisBehaviour)
 {
     Debug.LogError("Do not attach base HaggisCommand to objects");
 }
Exemplo n.º 13
0
 public override void DoStepOn(HaggisBehaviour haggisBehaviour)
 {
     haggisBehaviour.TryBuildStep(this, this.transform.position + Vector3.up, haggisBehaviour.transform.rotation);
 }