Exemplo n.º 1
0
        void TryAid(CellObjCtrl ctrl)
        {
            bool bCtrlling = CellObjCtrlUtils.IsControllingObj(ctrl);

            if (!bCtrlling)
            {
                return;
            }
            //bool bFwdCtrlling = CellObjCtrlUtils.IsNbCellControllingObj (_cellCtrl, 0);
            bool        bShouldAid   = ShouldAid();
            MiroModelV1 model        = ctrl._TgtObj.GetComponent <MiroModelV1> ();
            bool        bHasPump     = model.HasPump();
            bool        bAiding      = model.IsAiding();
            CellObjCtrl fwdCtrl      = CellObjCtrlUtils.GetFwdCellObjCtrl(ctrl);
            bool        bAidingRight = false;

            if (fwdCtrl._TgtObj != null)
            {
                //bAidingRight = model.IsAiding (modelTgt);
                //MiroModelV1 modelTgt = fwdCtrl._TgtObj.GetComponent<MiroModelV1> ();
                if (model.HasPump() && model._Pump.IsGrown())
                {
                    int         AidingDir = model._Pump.GetAidingRDir();
                    CellObjCtrl nbCtrl    = CellObjCtrlUtils.GetNbCellObjCtrl(fwdCtrl, AidingDir);
                    if (nbCtrl == ctrl)
                    {
                        bAidingRight = true;
                    }
                }
            }
            if (bShouldAid)
            {
                bool bRight = _mgr.IsPumpingRight(ctrl);
                if (bRight)
                {
                    //Debug.Log ("Aid Right");
                }
                else
                if (!bHasPump)
                {
                    _mgr.CreatePumpForAB(ctrl.transform, fwdCtrl.transform);
                }
                else
                {
                    if (!bAidingRight)
                    {
                        _mgr.RetargetPumpsFor(ctrl.transform);
                        //Debug.Log ("_mgr.RetargetPumpsFor (_cellCtrl.transform);");
                    }
                    else
                    {
                        if (!bAiding)
                        {
                            //model._GrowPumpTrigger = true;
                            model.GrowUpPump();
                            //Debug.Log ("GrowUpPump: " + model);
                        }
                        else
                        {
                            model.ShrinkPump();
                            //model._ShrinkPumpTrigger = true;
                        }
                    }
                }
            }
            else
            {
                model.ShrinkPump();
                //model._ShrinkPumpTrigger = true;
                //print ("model._ShrinkPumpTrigger = true;");
                if (bAiding)
                {
                }
            }
        }